}
}
+static void str2lab(char* dest, const QString& src, int len, const char* fmt,
+ int n)
+{
+ str2lab(dest, CSTR(src), len, fmt, n);
+}
+
static void pack_time(time_t t, int32_t* date, int32_t* time)
{
struct tm* tm;
}
if (TL->rte_name != NULL) {
- strncpy(trkhdr[idx].name, TL->rte_name, TRK_NAME_LEN);
+ strncpy(trkhdr[idx].name, CSTRc(TL->rte_name), TRK_NAME_LEN);
}
if (*(trkhdr[idx].name) == '\0') {
sprintf(trkhdr[idx].name, "T%03d", idx);
trkhdr[idx].name[TRK_NAME_LEN-1] = '\0';
if (TL->rte_desc != NULL) {
- strncpy(trkhdr[idx].comment, TL->rte_desc, TRK_COMMENT_LEN);
- l = strlen(TL->rte_desc);
+ strncpy(trkhdr[idx].comment, CSTRc(TL->rte_desc), TRK_COMMENT_LEN);
+ l = strlen(CSTRc(TL->rte_desc));
if (l < TRK_COMMENT_LEN-1) {
memset(trkhdr[idx].comment + l, ' ', TRK_COMMENT_LEN - l);
}
*c = '\0';
}
if (*str) {
+#if NEW_STRINGS
+ wpt->shortname = str;
+#else
xfree(wpt->shortname);
wpt->shortname = xstrdup(str);
+#endif
}
}
}
i = 0;
QUEUE_FOR_EACH(&route->waypoint_list, elem, tmp) {
- char* s1, *s2;
+ const char* s1, *s2;
i++;
wpt = (waypoint*) elem;
} else {
sout = QString("%1,%2,@,0").arg(s1).arg(s1);
}
+
bcr_write_line(fout, "STATION", &i, sout);
xfree(s1);
xfree(s2);
gbfile* file_out;
static int wpt_count;
char* fname;
- char* ident;
xasprintf(&fname, "%s-%d.wpt", ofname, wpt_count++);
file_out = gbfopen_le(fname, "wb", MYNAME);
gbfputc(bushnell_get_icon_from_name(wpt->icon_descr), file_out);
gbfputc(0x01, file_out); // Proximity alarm. 1 == "off", 3 == armed.
- ident = mkshort(mkshort_handle, wpt->shortname);
strncpy(tbuf, CSTRc(wpt->shortname), sizeof(tbuf));
tbuf[sizeof(tbuf)-1] = 0;
gbfwrite(tbuf, sizeof(tbuf), 1, file_out);
gbfwrite(padding, sizeof(padding), 1, file_out);
xfree(fname);
- xfree(ident);
gbfclose(file_out);
}
w->wpt_flags.cet_converted = 1;
#if NEW_STRINGS
- w->shortname = cet_convert_string(CSTRc(wpt->shortname));
- w->description = cet_convert_string(CSTRc(wpt->description));
- w->notes = cet_convert_string(CSTRc(wpt->notes));
+// w->shortname = cet_convert_string(wpt->shortname);
+// w->description = cet_convert_string(wpt->description);
+// w->notes = cet_convert_string(wpt->notes);
#else
w->shortname = cet_convert_string(CSTRc(wpt->shortname));
w->description = cet_convert_string(CSTRc(wpt->description));
break;
default:
if (col > 7) {
+#if NEW_STRINGS
+ wpt->description += " ";
+ wpt->description += c;
+#else
wpt->description = xstrappend(wpt->description, " ");
wpt->description = xstrappend(wpt->description, c);
+#endif
}
}
}
static void
write_waypt_cb(const waypoint* wpt)
{
- char* name;
+ QString name;
if (curr_index != target_index) {
return;
name = (snlen > 0) ? mkshort_from_wpt(sh, wpt) : csv_stringclean(wpt->shortname, " ");
- gbfprintf(fout, "W %s A ", name);
+ gbfprintf(fout, "W %s A ", CSTR(name));
gbfprintf(fout, "%.10f%c%c ",
fabs(wpt->latitude), 0xBA, (wpt->latitude >= 0) ? 'N' : 'S');
gbfprintf(fout, "%.10f%c%c ",
wpt->icon_descr.isNull() ? "Waypoint" : wpt->icon_descr.toUtf8().data(),
WAYPT_GET(wpt, proximity, 0));
}
- xfree(name);
}
static void
write_route_hdr_cb(const route_head* rte)
{
- char* name;
curr_route = (route_head*) rte;
curr_index++;
if (curr_index != target_index) {
return;
}
- name = rte->rte_name;
+ QString name = rte->rte_name;
if (name != NULL) {
name = csv_stringclean(name, ",");
} else {
name = xstrdup(" ");
}
- gbfprintf(fout, "R 16711680,%s,1,-1\n", name);
- xfree(name);
+ gbfprintf(fout, "R 16711680,%s,1,-1\n", CSTR(name));
}
static void
if (track_info_flag != 0) {
track_info_flag = 0;
if (curr_track->rte_name != NULL) {
- char* name;
-
- name = csv_stringclean(curr_track->rte_name, "|");
- gbfprintf(fout, "t 4294967295|%s|-1|-1\n", name);
- xfree(name);
+ QString name = csv_stringclean(curr_track->rte_name, "|");
+ gbfprintf(fout, "t 4294967295|%s|-1|-1\n", CSTR(name));
}
}
}
line++;
cin = lrtrim(buff);
if (*cin != '\0') {
+#if NEW_STRINGS
+ wpt->notes = QString::fromLatin1(cin);
+#else
wpt->notes = xstrdup(cin);
+#endif
}
} else if (strcmp(cin + 2, "end") == 0) {
data = 1;
track = route_head_alloc();
track_add_head(track);
} else if (strncmp(name, "NAME:", 5) == 0) {
+#if NEW_STRINGS
+ wpt->shortname = QString::fromLatin1(((char*)&name) + 5);
+#else
wpt->shortname = xstrdup(((char*)&name) + 5);
+#endif
}
pow = strrchr(cin, '^');
}
static void
-write_wcstr(const char* str)
+write_wcstr(const QString& str)
{
int len;
short* unicode;
- unicode = cet_str_utf8_to_uni(str, &len);
+ unicode = cet_str_utf8_to_uni(CSTR(str), &len);
gbfwrite((void*)unicode, 2, len + 1, fout);
xfree(unicode);
}
garmin_fs_t* gmsd = GMSD_FIND(wpt);
write_wcstr(DST_DYN_POI);
+#if NEW_STRINGS
+ write_wcstr((!wpt->shortname.isEmpty()) ? CSTRc(wpt->shortname) : "WPT");
+ write_wcstr((!wpt->notes.isEmpty()) ? wpt->notes : wpt->description);
+#else
write_wcstr((wpt->shortname) ? CSTRc(wpt->shortname) : "WPT");
write_wcstr((wpt->notes) ? wpt->notes : wpt->description);
+#endif
write_wcstr(NULL); /* house number */
write_wcstr(GMSD_GET(addr, NULL)); /* street */
destinator_rtept_disp(const waypoint* wpt)
{
write_wcstr(DST_ITINERARY);
+#if NEW_STRINGS
+ write_wcstr((!wpt->shortname.isEmpty()) ? wpt->shortname : "RTEPT");
+ write_wcstr((!wpt->notes.isEmpty()) ? wpt->notes : wpt->description);
+#else
write_wcstr((wpt->shortname) ? CSTRc(wpt->shortname) : "RTEPT");
write_wcstr((wpt->notes) ? wpt->notes : wpt->description);
+#endif
gbfputint32(0, fout);
gbfputdbl(0, fout);
static char* xmlbin;
static waypoint* xmlwpt;
static route_head* xmltrk;
-static char* xmlgrid;
+static QString xmlgrid;
static int xmldatum;
static double xmlEasting, xmlNorthing;
static double xmlLatitude, xmlLongitude;
static void
finalize_pt(waypoint* wpt)
{
- if (strcmp(xmlgrid, "BNG") == 0) {
+ if (xmlgrid == "BNG") {
GPS_Math_NGENToAiry1830LatLon(xmlEasting, xmlNorthing,
&wpt->latitude, &wpt->longitude);
xmldatum = DATUM_OSGB36;
static void
tlog3a_xgcb_version(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ if (args != "1") {
+#else
if (strcmp(args, "1") != 0) {
- fatal(MYNAME ": Unsupported file version '%s'!\n", args);
+#endif
+ fatal(MYNAME ": Unsupported file version '%s'!\n", CSTRc(args));
}
}
char* bin;
char* cin, *cout;
char cl, ch;
-
+#if NEW_STRINGS
+// This function needs rethinking.
+ len = args.length();
+#else
len = strlen(args);
+#endif
bin = (char*) xmalloc((len >> 1) + 1);
+#if NEW_STRINGS
+ char* cincopy = xstrdup(args);
+ cin = cincopy;
+#else
cin = (char*)args;
+#endif
cout = bin;
cl = 0x10;
}
xmlbin = bin;
xmlbinsize = (cout - bin);
+#if NEW_STRINGS
+ xfree(cincopy);
+#endif
}
#endif
xmltrk = route_head_alloc();
track_add_head(xmltrk);
}
+#if NEW_STRINGS
+ xmltrk->rte_name = args;
+#else
xmltrk->rte_name = strdup(args);
+#endif
}
xmltrk = route_head_alloc();
track_add_head(xmltrk);
}
+#if NEW_STRINGS
+ xmltrk->rte_desc = args;
+#else
xmltrk->rte_desc = strdup(args);
+#endif
}
static void
tlog3b_xgcb_wptid(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ xmlwpt->shortname = args;
+#else
if (*args) {
xmlwpt->shortname = xstrdup(args);
}
+#endif
}
static void
tlog3b_xgcb_wptgr(xg_string args, const QXmlStreamAttributes* unused)
{
+ xmlgrid = args;
+/*
if (xmlgrid != NULL) {
if (strcmp(xmlgrid, args) == 0) {
return;
xfree(xmlgrid);
}
xmlgrid = xstrdup(args);
+*/
}
static void
tlog3b_xgcb_wptno(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ xmlNorthing = args.toDouble();
+#else
xmlNorthing = atof(args);
+#endif
}
static void
tlog3b_xgcb_wptea(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ xmlEasting = args.toDouble();
+#else
xmlEasting = atof(args);
+#endif
}
static void
tlog3b_xgcb_wptal(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ xmlAltitude = args.toDouble();
+#else
xmlAltitude = atof(args);
+#endif
}
}
}
+static void
+write_str(const QString& str, gbfile* f)
+{
+ write_str(CSTR(str), f);
+}
+
static int
read_datum(gbfile* f)
{
xmlbin = NULL;
xmltrk = NULL;
xmlwpt = NULL;
- xmlgrid = NULL;
+ xmlgrid = QString();
}
static void
dmtlog_rd_deinit(void)
{
gbfclose(fin);
- if (xmlgrid != NULL) {
- xfree(xmlgrid);
- }
}
static void
queue* curr, *prev;
QUEUE_FOR_EACH(&trk->waypoint_list, curr, prev) count++;
}
+#if NEW_STRINGS
+ if (!trk || trk->rte_name.isEmpty()) {
+ write_str("Name", fout);
+ } else {
+ write_str(trk->rte_name, fout);
+ }
+#else
write_str(trk && trk->rte_name && *trk->rte_name ? CSTRc(trk->rte_name) : "Name", fout);
+#endif
xasprintf(&cout, "%d trackpoints and %d waypoints", count, waypt_count());
write_str(cout, fout);
gbfputdbl(wpt->altitude != unknown_alt ? wpt->altitude : 0, fout);
names = 1;
+#if NEW_STRINGS
+ if (!wpt->description.isEmpty()) {
+#else
if (wpt->description && *wpt->description) {
+#endif
names = 2;
}
gbfputint32(names, fout);
if (names > 1) {
write_str(wpt->description, fout);
}
+#if NEW_STRINGS
+ write_str(wpt->shortname.isEmpty() ? "Name" : wpt->shortname, fout);
+#else
write_str(wpt->shortname && *wpt->shortname ? CSTRc(wpt->shortname) : "Name", fout);
+#endif
}
static void
memset(&dupe, '\0', sizeof(dupe));
if (snopt) {
- strncpy(dupe.shortname, waypointp->shortname, sizeof(dupe.shortname) - 1);
+ strncpy(dupe.shortname, CSTRc(waypointp->shortname), sizeof(dupe.shortname) - 1);
}
if (lcopt) {
ez_disp(const waypoint* wpt)
{
gbfputc('W', file_out);
-
+#if NEW_STRINGS
+ if (!wpt->shortname.isEmpty()) {
+#else
if (wpt->shortname) {
+#endif
gbfputc(1, file_out);
gbfputpstr(wpt->shortname, file_out);
}
+#if NEW_STRINGS
+ if (!wpt->description.isEmpty()) {
+#else
if (wpt->description) {
+#endif
gbfputc(3, file_out);
gbfputpstr(wpt->description, file_out);
}
gbfputc(0x64, file_out);
gbfputdbl(wpt->longitude, file_out);
-
+#if NEW_STRINGS
+ if (!wpt->notes.isEmpty()) {
+#else
if (wpt->notes) {
+#endif
gbfputc(5, file_out);
gbfputpstr(wpt->notes, file_out);
}
if (((c = strchr(cx, '.'))) && (c != cx)) {
*c = '\0';
}
-
+#if NEW_STRINGS
+ wpt->shortname = cx;
+#else
if (wpt->shortname) {
xfree(wpt->shortname);
}
wpt->shortname = xstrdup(cx);
+#endif
xfree(str);
}
case WPT_cA_OFS + 1:
case WPT_c1_OFS + 1:
+#if NEW_STRINGS
+ wpt->shortname = cin;
+#else
if (wpt->shortname) {
xfree(wpt->shortname);
}
wpt->shortname = xstrdup(cin);
+#endif
break;
case WPT_cA_OFS + 4:
void type_s(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ type = args.compare("GPSData");
+#else
type = strcmp(args, "GPSData");
+#endif
}
void device_s(xg_string args, const QXmlStreamAttributes* unused)
if (type) {
return;
}
+#if NEW_STRINGS
+ if ((args == "OutputFromUnit")) {
+#else
if (0 == strcmp(args, "OutputFromUnit")) {
+#endif
xasprintf(&my_gdx_info->from_device.path, "%s%c%s",
mountpoint, GB_PATHSEP, path);
my_gdx_info->from_device.basename = xstrdup(base);
my_gdx_info->from_device.path,
my_gdx_info->from_device.basename,
my_gdx_info->from_device.extension);
+#if NEW_STRINGS
+ } if ((args == "InputToUnit")) {
+#else
} else if (0 == strcmp(args, "InputToUnit")) {
+#endif
xasprintf(&my_gdx_info->to_device.path, "%s%c%s",
mountpoint, GB_PATHSEP, path);
my_gdx_info->to_device.basename = xstrdup(base);
my_gdx_info->to_device.extension = xstrdup(ext);
} else {
- fatal(MYNAME ":Unknown direction '%s'\n", args);
+ fatal(MYNAME ":Unknown direction '%s'\n", CSTRc(args));
}
if (base) {
(void) gbfgetint16(fin); /* ? always 1 ? */
(void) gbfgetc(fin); /* seems to 1 when extra options present */
+#if NEW_STRINGS
+ wpt->shortname = QString::fromLatin1(gpi_read_string("Shortname"));
+#else
wpt->shortname = gpi_read_string("Shortname");
+#endif
while (gbftell(fin) < (gbsize_t)(pos + sz - 4)) {
int tag = gbfgetint32(fin);
break;
}
}
-
+#if NEW_STRINGS
+ if (wpt->description.isEmpty() && !wpt->notes.isEmpty()) {
+ wpt->description = wpt->notes;
+ }
+ if (wpt->notes.isEmpty() && !wpt->description.isEmpty()) {
+ wpt->notes = wpt->description;
+ }
+#else
if (wpt->notes && !wpt->description) {
wpt->description = xstrdup(wpt->notes);
}
if (wpt->description && !wpt->notes) {
wpt->notes = xstrdup(wpt->description);
}
+#endif
waypt_add(wpt);
/* speed isn't part of a normal waypoint
WAYPT_SET(wpt, speed, speed);
*/
+#if NEW_STRINGS
+ if ((wpt->shortname.isEmpty() || (wpt->shortname).indexOf('@'))) {
+#else
if ((wpt->shortname == NULL) || (! strchr(wpt->shortname, '@'))) {
+#endif
if (units == 's') {
speed = MPS_TO_MPH(speed);
} else {
speed = MPS_TO_KPH(speed);
}
+#if NEW_STRINGS
+// double check
+ QString base = wpt->shortname.isEmpty() ? "WPT" : wpt->shortname;
+ wpt->shortname = base + QString("@.%1").arg(speed);
+#else
xasprintf(&str, "%s@%.f", wpt->shortname ? CSTRc(wpt->shortname) : "WPT", speed);
if (wpt->shortname) {
xfree(wpt->shortname);
}
wpt->shortname = str;
+#endif
}
}
break;
}
+#if NEW_STRINGS
+ if (!wpt->description.isEmpty()) {
+#else
if (wpt->description) {
+#endif
wpt->notes = str;
} else {
+#if NEW_STRINGS
+ wpt->description = QString::fromLatin1(str);
+#else
wpt->description = str;
+#endif
}
break;
gbfwrite(str, 1, len, fout);
}
+static void
+write_string(const QString& str, const char long_format)
+{
+ write_string(CSTR(str), long_format);
+}
+
static int
compare_wpt_cb(const queue* a, const queue* b)
{
const waypoint* wa = (waypoint*) a;
const waypoint* wb = (waypoint*) b;
-
+#if NEW_STRINGS
+ return wa->shortname.compare(wb->shortname);
+#else
return strcmp(wa->shortname, wb->shortname);
+#endif
}
+static char
+compare_strings(const QString& s1, const QString& s2)
+{
+ return s1.compare(s2);
+}
+#if !NEW_STRINGS
static char
compare_strings(const char* s1, const char* s2)
{
return 1;
}
}
+#endif
static writer_data_t*
waypoint* wpt = (waypoint*) elem;
gpi_waypt_t* dt;
garmin_fs_t* gmsd;
- char* str;
+ QString str;
res += 12; /* tag/sz/sub-sz */
res += 19; /* poi fixed size */
+#if NEW_STRINGS
+ res += wpt->shortname.length();
+#else
res += strlen(wpt->shortname);
+#endif
if (! opt_hide_bitmap) {
res += 10; /* tag(4) */
}
if (alerts) {
char* pos;
-
+#if NEW_STRINGS
+// examine closely.
+ QString t = wpt->shortname.mid(wpt->shortname.indexOf('@'));
+ if ((pos = xstrdup(CSTR(t)))) {
+#else
if ((pos = strchr(wpt->shortname, '@'))) {
+#endif
double speed, scale;
if (units == 's') {
scale = MPH_TO_MPS(1);
}
}
- str = NULL;
+ str = QString();
if (opt_descr) {
+#if NEW_STRINGS
+ if (!wpt->description.isEmpty()) {
+#else
if (wpt->description && *wpt->description) {
+#endif
str = xstrdup(wpt->description);
}
} else if (opt_notes) {
+#if NEW_STRINGS
+ if (!wpt->notes.isEmpty()) {
+#else
if (wpt->notes && *wpt->notes) {
+#endif
str = xstrdup(wpt->notes);
}
} else if (opt_pos) {
}
- if (str) {
+ if (!str.isEmpty()) {
dt->addr_is_dynamic = 1;
- dt->addr = str;
+ dt->addr = xstrdup(CSTR(str));
dt->mask |= GPI_ADDR_ADDR;
dt->sz += (8 + strlen(dt->addr));
}
}
str = wpt->description;
- if (! str) {
+ if (str.isEmpty()) {
str = wpt->notes;
}
// if (str && (strcmp(str, wpt->shortname) == 0)) str = NULL;
- if (str) {
- res += (12 + 4 + strlen(str));
+ if (!str.isEmpty()) {
+ res += (12 + 4 + str.length());
}
}
gbfputc(data->alert, fout);
QUEUE_FOR_EACH(&data->Q, elem, tmp) {
- char* str;
+ QString str;
int s0, s1;
waypoint* wpt = (waypoint*)elem;
gpi_waypt_t* dt = (gpi_waypt_t*) wpt->extra_data;
str = wpt->description;
- if (! str) {
+ if (str.isEmpty()) {
str = wpt->notes;
}
// if (str && (strcmp(str, wpt->shortname) == 0)) str = NULL;
gbfputint32(0x80002, fout);
-
+#if NEW_STRINGS
+ s0 = s1 = 19 + wpt->shortname.length();
+#else
s0 = s1 = 19 + strlen(wpt->shortname);
+#endif
if (! opt_hide_bitmap) {
s0 += 10; /* tag(4) */
}
- if (str) {
- s0 += (12 + 4 + strlen(str)); /* descr */
+ if (!str.isEmpty()) {
+ s0 += (12 + 4 + str.length()); /* descr */
}
if (dt->sz) {
s0 += (12 + dt->sz); /* address part */
gbfputint16(0, fout);
}
- if (str) {
+ if (!str.isEmpty()) {
gbfputint32(0xa, fout);
- gbfputint32(strlen(str) + 8, fout); /* string + string header */
+ gbfputint32(str.length() + 8, fout); /* string + string header */
write_string(str, 1);
}
enum_waypt_cb(const waypoint* ref)
{
waypoint* wpt;
- char* str;
queue* elem, *tmp;
QUEUE_FOR_EACH(&wdata->Q, elem, tmp) {
wpt = waypt_dupe(ref);
+ QString str;
if (*opt_unique == '1') {
str = mkshort(short_h, wpt->shortname);
+#if NEW_STRINGS
+ wpt->shortname = str;
+#else
xfree(wpt->shortname);
wpt->shortname = str;
+#endif
}
wdata_add_wpt(wdata, wpt);
}
const char*
-gt_get_icao_country(const char* cc)
+gt_get_icao_country(const QString& cc)
{
gt_country_code_t* x = >_country_codes[0];
- if ((cc == NULL) || (*cc == '\0')) {
+ if (cc.isEmpty()) {
return NULL;
}
do {
const char* ccx = x->cc;
+ const QString qccx = x->cc;
while (ccx != NULL) {
- if (strncmp(ccx, cc, 2) == 0) {
+ if (qccx.left(2) == cc) {
return x->country;
}
if ((ccx[0] == cc[0]) && (ccx[1] == '*')) {
}
const char*
-gt_get_icao_cc(const char* country, const char* shortname)
+gt_get_icao_cc(const QString& country, const QString& shortname)
{
static char res[3];
gt_country_code_t* x = >_country_codes[0];
- if ((country == NULL) || (*country == '\0')) {
+ if (country.isEmpty()) {
const char* test;
if (shortname == NULL) {
return NULL;
}
- switch (strlen(shortname)) {
+ switch (shortname.length()) {
case 3:
- strncpy(res, shortname, 1);
+ strncpy(res, CSTR(shortname), 1);
break;
case 4:
- strncpy(res, shortname, 2);
+ strncpy(res, CSTR(shortname), 2);
break;
default:
return NULL;
}
do {
- if (case_ignore_strcmp(country, x->country) != 0) {
+ if (country.compare(x->country, Qt::CaseInsensitive) != 0) {
x++;
continue;
}
}
return res;
}
- if (shortname && (strlen(shortname) == 4)) {
+ if (shortname.length() == 4) {
const char* ccx = x->cc;
- strncpy(res, shortname, 2);
+ strncpy(res, CSTR(shortname), 2);
res[2] = '\0';
while (ccx != NULL) {
if (strncmp(ccx, res, 2) == 0) {
extern gt_country_code_t gt_country_codes[];
-const char* gt_get_icao_country(const char* cc);
-const char* gt_get_icao_cc(const char* country, const char* shortname);
+const char* gt_get_icao_country(const QString& cc);
+const char* gt_get_icao_cc(const QString& country, const QString& shortname);
/* this order is used by most devices */
typedef enum {
{
const waypoint* wa = *(waypoint**)a;
const waypoint* wb = *(waypoint**)b;
-
+#if NEW_STRINGS
+ return wa->shortname.compare(wb->shortname, Qt::CaseInsensitive);
+#else
return case_ignore_strcmp(QString::fromLatin1(wa->shortname), QString::fromLatin1(wb->shortname));
+#endif
}
if (! valid) {
gbfprintf(fout, "#####\n");
fatal(MYNAME ": %s (%s) is outside of convertable area \"%s\"!\n",
+#if NEW_STRINGS
+ wpt->shortname.isEmpty() ? "Waypoint" : CSTR(wpt->shortname),
+#else
wpt->shortname ? CSTRc(wpt->shortname) : "Waypoint",
+#endif
pretty_deg_format(wpt->latitude, wpt->longitude, 'd', NULL, 0),
gt_get_mps_grid_longname(grid_index, MYNAME));
}
wpt_type = gt_waypt_class_names[0];
}
+#if NEW_STRINGS
+ gbfprintf(fout, "Waypoint\t%s\t", CSTRc(wpt->shortname));
+#else
gbfprintf(fout, "Waypoint\t%s\t", (wpt->shortname) ? CSTRc(wpt->shortname) : "");
+#endif
if (wpt_class <= gt_waypt_class_airport_ndb) {
- const char* temp = wpt->notes;
- if (temp == NULL) {
+ QString temp = wpt->notes;
+ if (temp.isEmpty()) {
+#if NEW_STRINGS
+ if (wpt->description != wpt->shortname) {
+#else
if (wpt->description && (strcmp(wpt->description, wpt->shortname) != 0)) {
+#endif
temp = wpt->description;
} else {
temp = "";
gtxt_flags.route_header_written = 1;
gbfprintf(fout, "\r\n\r\nHeader\t%s\r\n", headers[route_header]);
}
-
+#if NEW_STRINGS
+ print_string("\r\nRoute\t%s\t", current_trk->rte_name);
+#else
print_string("\r\nRoute\t%s\t", current_trk->rte_name ? CSTRc(current_trk->rte_name) : "");
+#endif
print_distance(cur_info->length, 0, 1, 0);
print_course(cur_info->first_wpt, cur_info->last_wpt);
gbfprintf(fout, "\t%d waypoints\t", cur_info->count);
gtxt_flags.track_header_written = 1;
gbfprintf(fout, "\r\n\r\nHeader\t%s\r\n", headers[track_header]);
}
-
+#if NEW_STRINGS
+ print_string("\r\nTrack\t%s\t", current_trk->rte_name);
+#else
print_string("\r\nTrack\t%s\t", current_trk->rte_name ? CSTRc(current_trk->rte_name) : "");
+#endif
print_date_and_time(cur_info->start, 0);
print_date_and_time(cur_info->time, 1);
print_distance(cur_info->length, 0, 1, 0);
void gl_trk_lat(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->latitude = args.toDouble();
+#else
wpt_tmp->latitude = atof(args);
+#endif
}
void gl_trk_long(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->longitude = args.toDouble();
+#else
wpt_tmp->longitude = atof(args);
+#endif
}
void gl_trk_alt(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->altitude = args.toDouble();
+#else
wpt_tmp->altitude = atof(args);
+#endif
}
static int serial = 0;
#define MYNAME "google"
-#define MY_CBUF 4096
static xg_callback goog_points, goog_levels, goog_poly_e, goog_script;
static xg_callback goog_segment_s, goog_segment, goog_td_s, goog_td_b;
void goog_script(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ if (true) {
+#else
if (args) {
+#endif
if (script) {
- script = xstrappend(script, args);
+ script = xstrappend(script, CSTRc(args));
} else {
script = xstrdup(args);
}
void goog_points(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ if (true) {
+#else
if (args) {
+#endif
if (encoded_points) {
- encoded_points = xstrappend(encoded_points, args);
+ encoded_points = xstrappend(encoded_points, CSTRc(args));
} else {
encoded_points = xstrdup(args);
}
void goog_levels(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ if (true) {
+#else
if (args) {
+#endif
if (encoded_levels) {
- encoded_levels = xstrappend(encoded_levels, args);
+ encoded_levels = xstrappend(encoded_levels, CSTRc(args));
} else {
encoded_levels = xstrdup(args);
}
wpt_tmp = route_find_waypt_by_name(routehead[goog_segroute], goog_segname);
if (wpt_tmp) {
+#if NEW_STRINGS
+#else
xfree(wpt_tmp->shortname);
- wpt_tmp->shortname = mkshort(desc_handle, args);
+#endif
+ wpt_tmp->shortname = mkshort(desc_handle, CSTRc(args));
wpt_tmp->description = xstrdup(args);
}
}
void goog_td_b(xg_string args, const QXmlStreamAttributes* unused)
{
- if (goog_segname[0] == '\\' && !strchr(args, '\xa0')) {
+ if (goog_segname[0] == '\\' && !strchr(CSTRc(args), '\xa0')) {
if (goog_realname) {
xfree(goog_realname);
goog_realname = NULL;
}
- goog_realname = (char*) xmalloc(strlen(args)+1);
- strcpy(goog_realname, args);
+ goog_realname = (char*) xmalloc(strlen(CSTRc(args))+1);
+ strcpy(goog_realname, CSTRc(args));
}
}
void goog_td_e(xg_string args, const QXmlStreamAttributes* unused)
wpt_tmp->longitude = lon / 100000.0;
wpt_tmp->route_priority=level;
wpt_tmp->shortname = (char*) xmalloc(7);
+#if NEW_STRINGS
+ wpt_tmp->shortname = QString().sprintf( "\\%5.5x", serial++);
+#else
sprintf(wpt_tmp->shortname, "\\%5.5x", serial++);
+#endif
route_add_wpt(routehead[goog_segroute], wpt_tmp);
}
}
#include "defs.h"
#include "xmlgeneric.h"
-static char* encoded_points = NULL;
-static char* instructions = NULL;
+static QString encoded_points;
+static QString instructions;
static short_handle desc_handle;
#define MYNAME "googledir"
void
goog_points(xg_string args, const QXmlStreamAttributes* unused)
{
- if (args) {
- if (encoded_points) {
- encoded_points = xstrappend(encoded_points, args);
- } else {
- encoded_points = xstrdup(args);
- }
- }
+ encoded_points += args;
}
void
goog_instr(xg_string args, const QXmlStreamAttributes* unused)
{
- if (args) {
- if (instructions) {
- instructions = xstrappend(instructions, args);
- } else {
- instructions = xstrdup(args);
- }
- }
+ instructions += args;
}
static int goog_step = 0;
{
long lat = 0;
long lon = 0;
- char* str = encoded_points;
+//NEW_STRINGS. Kind of silly to make a copy here.
+ char* ostr = xstrdup(encoded_points);
+ char* str = ostr;
route_head* routehead = route_head_alloc();
+#if NEW_STRINGS
+ if (args == "overview_polyline") {
+#else
if (strcmp(args, "overview_polyline") == 0) {
+#endif
routehead->rte_name = (char*) xstrdup("overview");
routehead->rte_desc = (char*) xstrdup("Overview");
} else {
} else {
utf_string utf;
utf.is_html = 1;
- utf.utfstring = QString::fromUtf8(instructions);
+ utf.utfstring = /*QString::fromUtf8*/(instructions);
routehead->rte_desc = strip_html(&utf);
- xfree(instructions);
- instructions = NULL;
+ instructions = QString();
}
}
route_add_head(routehead);
route_add_wpt(routehead, wpt_tmp);
}
}
-
- if (encoded_points) {
- xfree(encoded_points);
- encoded_points = NULL;
- }
- if (instructions) {
- xfree(instructions);
- instructions = NULL;
- }
+xfree(ostr);
+ encoded_points = QString();
+ instructions = QString();
}
static void
{
xml_read();
- if (encoded_points) {
- xfree(encoded_points);
- encoded_points = NULL;
- }
- if (instructions) {
- xfree(instructions);
- instructions = NULL;
- }
+ encoded_points = QString();
+ instructions = QString();
}
static void
gbfprintf(file_out, "%-8.8s %08.3f%c %09.3f%c %07.0f%c %-30.30s %s\n",
global_opts.synthesize_shortnames ?
- mkshort_from_wpt(mkshort_handle, wpt) :
- wpt->shortname,
+ CSTRc(mkshort_from_wpt(mkshort_handle, wpt)) :
+ CSTRc(wpt->shortname),
fabs(lat),
lat < 0.0 ? 'S' : 'N',
fabs(lon),
((wpt->altitude == unknown_alt) ||
(wpt->altitude < 0.0)) ? 0 : wpt->altitude,
'm',
- wpt->description ? tdesc : "",
+ CSTRc(wpt->description) ? tdesc : "",
icon_token.toUtf8().data());
xfree(tdesc);
we need to keep track of log_wpt counts so we don't collide with
dupe shortnames.
*/
+#if NEW_STRINGS
+ if (wpt_tmp->shortname.size() > 2) {
+// FIXME: think harder about this later.
+ lwp_tmp->shortname = wpt_tmp->shortname.mid(2, 4) + "-FIXME";
+
+#else
if ((wpt_tmp->shortname) && (strlen(wpt_tmp->shortname) > 2)) {
/* copy of the shortname */
lwp_tmp->shortname = (char*) xcalloc(7, 1);
sprintf(lwp_tmp->shortname, "%-4.4s%02d",
&wpt_tmp->shortname[2], logpoint_ct++);
-
+#endif
waypt_add(lwp_tmp);
}
}
wpt_tmp = NULL;
break;
case tt_cache_name:
+#if NEW_STRINGS
+ wpt_tmp->notes = cdatastr;
+#else
if (wpt_tmp->notes != NULL) {
xfree(wpt_tmp->notes);
}
wpt_tmp->notes = xstrdup(cdatastr);
+#endif
break;
case tt_cache_container:
waypt_alloc_gc_data(wpt_tmp)->container = gs_mkcont(cdatastr);
case tt_wpt_desc:
case tt_trk_trkseg_trkpt_desc:
case tt_rte_rtept_desc:
+#if NEW_STRINGS
+ wpt_tmp->notes = cdatastr;
+#else
if (wpt_tmp->notes != NULL) {
xfree(wpt_tmp->notes);
}
wpt_tmp->notes = xstrdup(cdatastr);
+#endif
break;
case tt_pdop:
wpt_tmp->pdop = cdatastr.toDouble();
current_trk_head = rte;
writer->writeStartElement("trk");
+#if NEW_STRINGS
+ writer->writeOptionalTextElement("name", rte->rte_name);
+ writer->writeOptionalTextElement("desc", rte->rte_desc);
+#else
writer->writeOptionalTextElement("name", QString::fromUtf8(rte->rte_name));
writer->writeOptionalTextElement("desc", QString::fromUtf8(rte->rte_desc));
+#endif
if (rte->rte_num) {
writer->writeTextElement("number", QString::number(rte->rte_num));
}
static void
gpx_track_disp(const waypoint* waypointp)
{
- const char* oname;
fs_xml* fs_gpx;
int first_in_trk;
first_in_trk = waypointp->Q.prev == ¤t_trk_head->waypoint_list;
/* GPX doesn't require a name on output, so if we made one up
* on input, we might as well say nothing.
*/
+#if NEW_STRINGS
+ QString oname;
+#else
+ const char* oname;
+#endif
oname = global_opts.synthesize_shortnames ?
mkshort_from_wpt(mkshort_handle, waypointp) :
waypointp->shortname;
static void
gpx_route_disp(const waypoint* waypointp)
{
+#if NEW_STRINGS
+ QString oname;
+#else
const char* oname;
+#endif
fs_xml* fs_gpx;
writer->writeStartElement("rtept");
writer->writeAttribute("lat", toString(waypointp->latitude));
va_end(args);
}
+static void
+gtc_write_xml(int indent, const QString s)
+{
+ if (indent < 0) {
+ gtc_indent_level--;
+ }
+ gbfprintf(ofd, "%*s", gtc_indent_level * 2, "");
+ gbfputs(s, ofd);
+ if (indent > 0) {
+ gtc_indent_level++;
+ }
+
+
+}
+
static void
gtc_lap_start(const route_head* rte)
{
gtc_lap_start(NULL);
gtc_new_study_lap(rte);
route_disp(rte, gtc_study_lap);
+#if NEW_STRINGS
+ if (!rte->rte_name.isEmpty()) {
+ QString name = rte->rte_name.left(GTC_MAX_NAME_LEN);
+ gtc_write_xml(0, QString("<Name>%1</Name>\n").arg(name));
+#else
if (rte->rte_name) {
char* name = xstrndup(rte->rte_name, GTC_MAX_NAME_LEN);
gtc_write_xml(0, "<Name>%s</Name>\n", name);
xfree(name);
+#endif
} else {
gtc_write_xml(0, "<Name>New Course</Name>\n");
}
}
void
-gtc_trk_s(const char* unused, const QXmlStreamAttributes* unusedattrs)
+gtc_trk_s(const xg_string unused, const QXmlStreamAttributes* unusedattrs)
{
trk_head = route_head_alloc();
track_add_head(trk_head);
}
void
-gtc_trk_lap_s(const char* unused, const QXmlStreamAttributes* unusedattrs)
+gtc_trk_lap_s(xg_string unused, const QXmlStreamAttributes* unusedattrs)
{
lap_ct++;
lap_s = 1;
}
void
-gtc_trk_lap_e(const char* unused, const QXmlStreamAttributes* unusedattrs)
+gtc_trk_lap_e(xg_string unused, const QXmlStreamAttributes* unusedattrs)
{
lap_s = 0;
}
void
-gtc_trk_pnt_s(const char* unused, const QXmlStreamAttributes* unusedattrs)
+gtc_trk_pnt_s(xg_string unused, const QXmlStreamAttributes* unusedattrs)
{
wpt_tmp = waypt_new();
}
void
-gtc_trk_pnt_e(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_trk_pnt_e(xg_string args, const QXmlStreamAttributes* unused)
{
if (wpt_tmp->longitude != 0. && wpt_tmp->latitude != 0.) {
if (lap_s) {
}
void
-gtc_trk_utc(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_trk_utc(xg_string args, const QXmlStreamAttributes* unused)
{
wpt_tmp->creation_time = xml_parse_time(args);
}
void
-gtc_trk_lat(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_trk_lat(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->latitude = args.toDouble();
+#else
wpt_tmp->latitude = atof(args);
+#endif
}
void
-gtc_trk_long(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_trk_long(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->longitude = args.toDouble();
+#else
wpt_tmp->longitude = atof(args);
+#endif
}
+#if NEW_STRINGS
+void
+gtc_trk_alt(xg_string args, const QXmlStreamAttributes* unused)
+{
+ wpt_tmp->altitude = args.toDouble();
+}
+#else
void
-gtc_trk_alt(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_trk_alt(xg_string args, const QXmlStreamAttributes* unused)
{
wpt_tmp->altitude = atof(args);
}
+#endif
+#if NEW_STRINGS
+void gtc_trk_dist(const QString& args, const QXmlStreamAttributes* unused)
+{
+ wpt_tmp->odometer_distance = args.toDouble();
+}
+void gtc_trk_hr(const QString& args, const QXmlStreamAttributes* unused)
+{
+ wpt_tmp->heartrate = args.toDouble();
+}
+void gtc_trk_cad(const QString& args, const QXmlStreamAttributes* unused)
+{
+ wpt_tmp->cadence = args.toDouble();
+}
+#else
void
-gtc_trk_dist(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_trk_dist(xg_string args, const QXmlStreamAttributes* unused)
{
wpt_tmp->odometer_distance = atof(args);
}
void
-gtc_trk_hr(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_trk_hr(xg_string args, const QXmlStreamAttributes* unused)
{
wpt_tmp->heartrate = atoi(args);
}
void
-gtc_trk_cad(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_trk_cad(xg_string args, const QXmlStreamAttributes* unused)
{
wpt_tmp->cadence = atoi(args);
}
+#endif
+#if NEW_STRINGS
+void
+gtc_trk_pwr(xg_string args, const QXmlStreamAttributes* unused)
+{
+ wpt_tmp->power = args.toDouble();
+}
+#else
void
-gtc_trk_pwr(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_trk_pwr(xg_string args, const QXmlStreamAttributes* unused)
{
wpt_tmp->power = atof(args);
}
+#endif
void
-gtc_trk_spd(xg_string args, const QXmlStreamAttributes* unusedd)
+#if NEW_STRINGS
+gtc_trk_spd(xg_string args, const QXmlStreamAttributes* unused)
+{
+ WAYPT_SET(wpt_tmp, speed, args.toDouble());
+}
+#else
+gtc_trk_spd(xg_string args, const QXmlStreamAttributes* unused)
{
WAYPT_SET(wpt_tmp, speed, atof(args));
}
+#endif
void
+#if NEW_STRINGS
+gtc_wpt_crs_s(const QString& args, const QXmlStreamAttributes* unused)
+#else
gtc_wpt_crs_s(const char* unused, const QXmlStreamAttributes* unusedattrs)
+#endif
{
wpt_tmp = waypt_new();
}
void
-gtc_wpt_crs_e(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_wpt_crs_e(xg_string args, const QXmlStreamAttributes* unused)
{
if (wpt_tmp->longitude != 0. && wpt_tmp->latitude != 0.) {
waypt_add(wpt_tmp);
}
void
-gtc_wpt_pnt_s(const char* unused, const QXmlStreamAttributes* unusedattrs)
+gtc_wpt_pnt_s(xg_string unused, const QXmlStreamAttributes* unusedattrs)
{
wpt_tmp = waypt_new();
lap_ct++;
}
void
-gtc_wpt_pnt_e(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_wpt_pnt_e(xg_string args, const QXmlStreamAttributes* unused)
{
if (wpt_tmp->longitude != 0. && wpt_tmp->latitude != 0.) {
/* Add the begin position of a CourseLap as
wpt_tmp = NULL;
}
+#if NEW_STRINGS
+void gtc_wpt_ident(const QString& args, const QXmlStreamAttributes* unused)
+{
+ wpt_tmp->shortname = (args);
+ /* Set also as notes for compatibility with garmin usb format */
+ wpt_tmp->notes = (args);
+}
+void gtc_wpt_lat(const QString& args, const QXmlStreamAttributes* unused)
+{
+ wpt_tmp->latitude = args.toDouble();
+}
+void gtc_wpt_long(const QString& args, const QXmlStreamAttributes* unused)
+{
+ wpt_tmp->longitude = args.toDouble();
+}
+void gtc_wpt_icon(const QString& args, const QXmlStreamAttributes* unused)
+{
+ wpt_tmp->icon_descr = args;
+}
+void gtc_wpt_notes(const QString& args, const QXmlStreamAttributes* unused)
+{
+ wpt_tmp->description = args;
+}
+#else
void
-gtc_wpt_ident(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_wpt_ident(xg_string args, const QXmlStreamAttributes* unused)
{
wpt_tmp->shortname = xstrdup(args);
/* Set also as notes for compatibility with garmin usb format */
}
void
-gtc_wpt_lat(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_wpt_lat(xg_string args, const QXmlStreamAttributes* unused)
{
wpt_tmp->latitude = atof(args);
}
void
-gtc_wpt_long(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_wpt_long(xg_string args, const QXmlStreamAttributes* unused)
{
wpt_tmp->longitude = atof(args);
}
void
-gtc_wpt_icon(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_wpt_icon(xg_string args, const QXmlStreamAttributes* unused)
{
wpt_tmp->icon_descr = args;
}
void
-gtc_wpt_notes(xg_string args, const QXmlStreamAttributes* unusedd)
+gtc_wpt_notes(xg_string args, const QXmlStreamAttributes* unused)
{
wpt_tmp->description = xstrdup(args);
}
+#endif
ff_vecs_t gtc_vecs = {
ff_type_file,
static
void ht_lat(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->latitude = args.toDouble();
+#else
wpt_tmp->latitude = atof(args);
+#endif
}
static
void ht_long(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->longitude = args.toDouble();
+#else
wpt_tmp->longitude = atof(args);
+#endif
}
static
void ht_alt(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->altitude = args.toDouble();
+#else
wpt_tmp->altitude = atof(args);
+#endif
}
static
struct tm tm;
time_t utc;
- sscanf(args, "%d-%d-%d %d:%d:%d",
+ sscanf(CSTRc(args), "%d-%d-%d %d:%d:%d",
&tm.tm_year, &tm.tm_mon,
&tm.tm_mday, &tm.tm_hour,
&tm.tm_min, &tm.tm_sec);
static
void ht_trk_lat(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->latitude = args.toDouble();
+#else
wpt_tmp->latitude = atof(args);
+#endif
}
static
void ht_trk_long(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->longitude = args.toDouble();
+#else
wpt_tmp->longitude = atof(args);
+#endif
}
static
void ht_trk_alt(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->altitude = args.toDouble();
+#else
wpt_tmp->altitude = atof(args);
+#endif
}
-char* mknshort(char* stIn,unsigned int sLen)
+const char* mknshort(const char* stIn,unsigned int sLen)
{
#define MAX_STRINGLEN 255
static char strOut[MAX_STRINGLEN];
memset(pWptHxTmp->name,0x20,sizeof(pWptHxTmp->name));
if (wpt->shortname != NULL) {
- strncpy(pWptHxTmp->name, mknshort(wpt->shortname,sizeof(pWptHxTmp->name)),sizeof(pWptHxTmp->name));
+ strncpy(pWptHxTmp->name, mknshort(CSTRc(wpt->shortname),sizeof(pWptHxTmp->name)),sizeof(pWptHxTmp->name));
} else {
sprintf(pWptHxTmp->name,"W%d",sIndex);
}
memset(pWptHxTmp->comment,0x20,sizeof(pWptHxTmp->comment));
if (wpt->description != NULL) {
- strncpy(pWptHxTmp->comment, mknshort(wpt->description,sizeof(pWptHxTmp->comment)),sizeof(pWptHxTmp->comment));
+ strncpy(pWptHxTmp->comment, mknshort(CSTRc(wpt->description),sizeof(pWptHxTmp->comment)),sizeof(pWptHxTmp->comment));
}
/*set the time */
gbfprintf(file_out, "\n<a name=\"%s\"><hr></a>\n", CSTRc(wpt->shortname));
gbfprintf(file_out, "<table width=\"100%%\">\n");
- gbfprintf(file_out, "<tr><td><p class=\"gpsbabelwaypoint\">%s - ",(global_opts.synthesize_shortnames) ? mkshort_from_wpt(mkshort_handle, wpt) : wpt->shortname);
+ gbfprintf(file_out, "<tr><td><p class=\"gpsbabelwaypoint\">%s - ",(global_opts.synthesize_shortnames) ? CSTRc(mkshort_from_wpt(mkshort_handle, wpt)) : CSTRc(wpt->shortname));
cout = pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], " ", 1);
gbfprintf(file_out, "%s (%d%c %6.0f %7.0f)", cout, utmz, utmzc, utme, utmn);
xfree(cout);
gbfprintf(file_out, " alt:%d", (int)((altunits[0]=='f')?METERS_TO_FEET(wpt->altitude):wpt->altitude));
}
gbfprintf(file_out, "<br>\n");
+#if NEW_STRINGS
+ if (wpt->description != wpt->shortname) {
+#else
if (strcmp(wpt->description, wpt->shortname)) {
+#endif
if (wpt->HasUrlLink()) {
- char* d = html_entitize(wpt->description);
+ char* d = html_entitize(CSTRc(wpt->description));
UrlLink link = wpt->GetUrlLink();
gbfprintf(file_out, "<a href=\"%s\">%s</a>", link.url_.toUtf8().data(), d);
xfree(d);
}
gbfprintf(file_out, "<p class=\"gpsbabelhint\"><strong>Hint:</strong> %s</p>\n", hint);
xfree(hint);
+#if NEW_STRINGS
+ } else if (!wpt->notes.isEmpty() && (wpt->description.isEmpty() || wpt->notes != wpt->description)) {
+#else
} else if (wpt->notes && (!wpt->description || strcmp(wpt->notes,wpt->description))) {
+#endif
gbfprintf(file_out, "<p class=\"gpsbabelnotes\">%s</p>\n", CSTRc(wpt->notes));
}
double lat, north, east;
int i;
int num_icons = sizeof(humminbird_icons) / sizeof(humminbird_icons[0]);
- char* name;
be_write16(&hum.num, waypoint_num++);
hum.zero = 0;
north = inverse_gudermannian_i1924(lat);
be_write32(&hum.north, si_round(north));
+ QString name;
name = (global_opts.synthesize_shortnames)
? mkshort_from_wpt(wptname_sh, wpt)
: mkshort(wptname_sh, wpt->shortname);
memset(&hum.name, 0, sizeof(hum.name));
- memcpy(&hum.name, name, strlen(name));
- xfree(name);
+ memcpy(&hum.name, CSTR(name), name.length());
gbfputuint32(WPT_MAGIC, fout);
gbfwrite(&hum, sizeof(hum), 1, fout);
trk_head = NULL;
last_time = 0;
if (trk->rte_waypt_ct > 0) {
- char* name;
+ QString name;
trk_head = (humminbird_trk_header_t*) xcalloc(1, sizeof(humminbird_trk_header_t));
trk_points = (humminbird_trk_point_t*) xcalloc(max_points, sizeof(humminbird_trk_point_t));
name = mkshort(trkname_sh, trk->rte_name);
- strncpy(trk_head->name, name, sizeof(trk_head->name));
- xfree(name);
+ strncpy(trk_head->name, CSTR(name), sizeof(trk_head->name));
be_write16(&trk_head->trk_num, trk->rte_num);
}
}
if (humrte->count > 0) {
int i;
- char* name;
humrte->num = rte_num++;
humrte->time = gpsbabel_time;
be_write16(&humrte->num, humrte->num);
be_write32(&humrte->time, humrte->time);
- name = mkshort(rtename_sh, rte->rte_name);
- strncpy(humrte->name, name, sizeof(humrte->name));
- xfree(name);
+ QString name = mkshort(rtename_sh, rte->rte_name);
+ strncpy(humrte->name, CSTR(name), sizeof(humrte->name));
gbfputuint32(RTE_MAGIC, fout);
gbfwrite(humrte, sizeof(*humrte), 1, fout);
static void
ignr_nb_etapes(xg_string args, const QXmlStreamAttributes* attrv)
{
+#if NEW_STRINGS
+ xmlpoints = args.toInt();
+#else
xmlpoints = atoi(args);
+#endif
}
static void
ignr_descr(xg_string args, const QXmlStreamAttributes* attrv)
{
ignr_xml_error((track == NULL));
-
+#if NEW_STRINGS
+qDebug() << args;
+ track->rte_desc = args;
+#else
if ((args != NULL) && (strlen(args) > 0)) {
track->rte_desc = xstrdup(args);
}
+#endif
}
static void
static void
ignr_etape_pos(xg_string args, const QXmlStreamAttributes* attrv)
{
+#if NEW_STRINGS
+ ignr_xml_error((wpt == NULL) || (args.isEmpty()));
+#else
ignr_xml_error((wpt == NULL) || (args == NULL));
+#endif
- if (2 != sscanf(args, "%lf,%lf", &wpt->latitude, &wpt->longitude)) {
- fatal(MYNAME ": Invalid coordinates \"%s\"!\n", args);
+ if (2 != sscanf(CSTRc(args), "%lf,%lf", &wpt->latitude, &wpt->longitude)) {
+ fatal(MYNAME ": Invalid coordinates \"%s\"!\n", CSTRc(args));
}
}
return;
}
- if (1 != sscanf(args, "%lf", &wpt->altitude)) {
- fatal(MYNAME ": Invalid altitude \"%s\"!\n", args);
+ if (1 != sscanf(CSTRc(args), "%lf", &wpt->altitude)) {
+ fatal(MYNAME ": Invalid altitude \"%s\"!\n", CSTRc(args));
}
}
iktobj_type(xg_string args, const QXmlStreamAttributes* unused)
{
ikt_object_end();
-
+#if NEW_STRINGS
+ switch (args.toInt()) {
+#else
switch (atoi(args)) {
+#endif
case 0:
waypt = waypt_new();
break;
track = route_head_alloc();
break;
default:
- fatal(MYNAME ": Unknown object type %s!\n", args);
+ fatal(MYNAME ": Unknown object type %s!\n", CSTRc(args));
}
}
timen += interval) {
waypoint* wpt_new = waypt_dupe(wpt);
wpt_new->SetCreationTime(timen);
+#if NEW_STRINGS
+ wpt_new->shortname = QString();
+ wpt_new->description = QString();
+#else
if (wpt_new->shortname) {
xfree(wpt_new->shortname);
}
xfree(wpt_new->description);
}
wpt_new->shortname = wpt_new->description = NULL;
+#endif
linepart(lat1, lon1,
wpt->latitude, wpt->longitude,
(double)(timen-time1)/
waypoint* wpt_new = waypt_dupe(wpt);
wpt_new->SetCreationTime(distn/curdist*
(wpt->creation_time.toTime_t() - time1) + time1);
+#if NEW_STRINGS
+ wpt_new->shortname = QString();
+ wpt_new->description = QString();
+#else
if (wpt_new->shortname) {
xfree(wpt_new->shortname);
}
xfree(wpt_new->description);
}
wpt_new->shortname = wpt_new->description = NULL;
+#endif
linepart(lat1, lon1,
wpt->latitude, wpt->longitude,
distn/curdist,
wpt_tmp_queued = 0;
}
+#if NEW_STRINGS
+void wpt_name(xg_string args, const QXmlStreamAttributes* unused)
+{
+ wpt_tmp->shortname = args;
+}
+#else
void wpt_name(xg_string args, const QXmlStreamAttributes* unused)
{
if (args) {
wpt_tmp->shortname = xstrdup(args);
}
}
+#endif
+#if NEW_STRINGS
+void wpt_desc(const QString& args, const QXmlStreamAttributes* unused)
+{
+ wpt_tmp->description += args.trimmed();
+}
+#else
void wpt_desc(xg_string args, const QXmlStreamAttributes* unused)
{
if (args) {
xfree(tmp);
}
}
+#endif
void wpt_time(xg_string args, const QXmlStreamAttributes* unused)
{
wpt_tmp->SetCreationTime(xml_parse_time(args));
}
-
+#if NEW_STRINGS
+void wpt_coord(const QString& args, const QXmlStreamAttributes* attrv)
+#else
void wpt_coord(xg_string args, const QXmlStreamAttributes* attrv)
+#endif
{
int n = 0;
double lat, lon, alt;
// Alt is actually optional.
- n = sscanf(args, "%lf,%lf,%lf", &lon, &lat, &alt);
+ n = sscanf(CSTRc(args), "%lf,%lf,%lf", &lon, &lat, &alt);
if (n >= 2) {
wpt_tmp->latitude = lat;
wpt_tmp->longitude = lon;
int n = 0;
route_head* trk_head = route_head_alloc();
+#if NEW_STRINGS
+ QString iargs = args;
+ if (!wpt_tmp->shortname.isEmpty()) {
+#else
if (wpt_tmp->shortname) {
+#endif
trk_head->rte_name = xstrdup(wpt_tmp->shortname);
}
track_add_head(trk_head);
-
+#if NEW_STRINGS
+ while ((n = sscanf(CSTR(iargs), "%lf,%lf,%lf%n", &lon, &lat, &alt, &consumed)) > 0) {
+#else
while ((n = sscanf(args, "%lf,%lf,%lf%n", &lon, &lat, &alt, &consumed)) > 0) {
+#endif
trkpt = waypt_new();
trkpt->latitude = lat;
// Line malformed or two-arg format without alt . Rescan.
if (2 == n) {
- sscanf(args, "%lf,%lf%n", &lon, &lat, &consumed);
+ sscanf(CSTRc(args), "%lf,%lf%n", &lon, &lat, &consumed);
}
if (3 == n) {
}
track_add_wpt(trk_head, trkpt);
-
+#if NEW_STRINGS
+ iargs = iargs.mid(consumed);
+#else
args += consumed;
+#endif
}
}
writer->writeStartElement("description");
hwriter.writeStartElement("table");
-
+#if NEW_STRINGS
+ if (!header->rte_desc.isEmpty()) {
+#else
if (header->rte_desc) {
+#endif
kml_td(hwriter, "Description", QString(" %1 ").arg(header->rte_desc));
}
kml_td(hwriter, "Distance", QString(" %1 %2 ").arg(QString::number(distance, 'f', 1)).arg(distance_units));
if (export_points) {
writer->writeStartElement("Placemark");
if (atoi(opt_labels)) {
+#if NEW_STRINGS
+ writer->writeOptionalTextElement("name", waypointp->shortname);
+#else
writer->writeOptionalTextElement("name", QString::fromUtf8(waypointp->shortname));
+#endif
}
writer->writeEmptyElement("snippet");
kml_output_description(waypointp);
writer->writeEndElement(); // Close Style tag
writer->writeStartElement("ExtendedData");
-
+#if NEW_STRINGS
+ if (!waypointp->shortname.isEmpty()) {
+#else
if (waypointp->shortname) {
+#endif
+
kml_write_data_element("gc_num", waypointp->shortname);
}
writer->writeTextElement("description", link.url_);
}
} else {
+#if NEW_STRINGS
+ if (waypointp->shortname != waypointp->description) {
+#else
if (strcmp(waypointp->shortname, waypointp->description)) {
+#endif
writer->writeOptionalTextElement("description", waypointp->description);
}
}
}
/* We want our waypoint to have a name, but not our trackpoint */
+#if NEW_STRINGS
+ if (wpt->shortname.isEmpty()) {
+#else
if (!wpt->shortname) {
+#endif
if (wpt->fix == fix_none) {
wpt->shortname = xstrdup("ESTIMATED Position");
} else {
switch (wpt->fix) {
case fix_none:
+#if NEW_STRINGS
+ wpt->shortname = "ESTIMATED Position";
+#else
if (wpt->shortname) {
xfree(wpt->shortname);
}
wpt->shortname = xstrdup("ESTIMATED Position");
+#endif
break;
case fix_unknown:
break;
static void
lmx_print(const waypoint* wpt)
{
- const char* oname;
- char* odesc;
- char tbuf[100];
+ QString oname;
+ QString odesc;
/*
* Desparation time, try very hard to get a good shortname
*/
odesc = wpt->notes;
- if (!odesc) {
+ if (odesc.isEmpty()) {
odesc = wpt->description;
}
- if (!odesc) {
+ if (odesc.isEmpty()) {
odesc = wpt->shortname;
}
if (!binary) {
gbfputc('\n', ofd);
}
- if (oname) {
+ if (!oname.isEmpty()) {
lmx_write_xml(0x48, oname, 3); // name
}
+#if NEW_STRINGS
+ if (!wpt->description.isEmpty()) {
+#else
if (wpt->description) {
+#endif
lmx_write_xml(0x49, wpt->description, 3); // description
}
lmx_start_tag(0x4A, 3); // coordinates
gbfputc('\n', ofd);
}
+ char tbuf[100];
sprintf(tbuf, "%f", wpt->latitude);
lmx_write_xml(0x4B, tbuf, 4); // latitude
static void
lmx_lm_lat(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->latitude = args.toDouble();
+#else
wpt_tmp->latitude = atof(args);
+#endif
}
static void
lmx_lm_lon(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->longitude = args.toDouble();
+#else
wpt_tmp->longitude = atof(args);
+#endif
}
static void
lmx_lm_alt(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->altitude = args.toDouble();
+#else
wpt_tmp->altitude = atof(args);
+#endif
}
static void
lmx_lm_name(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->shortname = args;
+#else
wpt_tmp->shortname = xstrdup(args);
+#endif
}
static void
lmx_lm_desc(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->description = args;
+#else
wpt_tmp->description = xstrdup(args);
+#endif
}
static void
{
int text_len, Lat, Lon, Time, SymbolId;
short int WayptType;
- char* name;
char* comment;
int alt = METERS_TO_FEET(wpt->altitude);
}
/* Try and make sure we have a name */
+#if NEW_STRINGS
+// this kind of thing would probably be more readable like
+// name = blah.
+// if name.isEmpty()
+// name = planB;
+// if name.isEmpty()
+// name = planC;
+// ...
+ QString name;
+ if ((wpt->shortname.isEmpty()) || global_opts.synthesize_shortnames) {
+ if (!wpt->description.isEmpty() && global_opts.synthesize_shortnames) {
+ name = mkshort_from_wpt(mkshort_handle, wpt);
+ } else if (!wpt->shortname.isEmpty()) {
+ name = wpt->shortname;
+ } else if (!wpt->description.isEmpty()) {
+ name = wpt->description;
+#else
if ((! wpt->shortname) || global_opts.synthesize_shortnames) {
if (wpt->description && global_opts.synthesize_shortnames) {
name = mkshort_from_wpt(mkshort_handle, wpt);
} else if (wpt->shortname) {
- name = xstrdup(wpt->shortname);
+ name = wpt->shortname;
} else if (wpt->description) {
- name = xstrdup(wpt->description);
- } else {
- name = xstrdup("");
+ name = wpt->description;
+#endif
}
} else {
- name = xstrdup(wpt->shortname);
+ name = wpt->shortname;
}
- text_len = strlen(name);
+ text_len = name.length();
if (text_len > MAXUSRSTRINGSIZE) {
text_len = MAXUSRSTRINGSIZE;
}
gbfputint32(text_len, file_out);
- gbfwrite(name, 1, text_len, file_out);
+ gbfwrite(CSTR(name), 1, text_len, file_out);
if (global_opts.debug_level >= 1) {
- printf(MYNAME " waypt_disp: Waypt name = %s\n",name);
+ printf(MYNAME " waypt_disp: Waypt name = %s\n", CSTR(name));
}
- xfree(name);
-
/**
* Comments are now used by the iFinder (Expedition C supports them)
*/
+#if NEW_STRINGS
+ if (wpt->description != wpt->shortname) {
+#else
if (wpt->description && strcmp(wpt->description, wpt->shortname) != 0) {
+#endif
comment = xstrdup(wpt->description);
text_len = strlen(comment);
if (text_len > MAXUSRSTRINGSIZE) {
char visible=1;
++trail_count;
+#if NEW_STRINGS
+// This whole function needs to be replaced...
+ if (!trk->rte_name.isEmpty()) {
+ name = xstrdup(trk->rte_name);
+ } else if (!trk->rte_desc.isEmpty()) {
+ name = xstrdup(trk->rte_desc);
+#else
if (trk->rte_name) {
name = xstrdup(trk->rte_name);
} else if (trk->rte_desc) {
name = xstrdup(trk->rte_desc);
+#endif
} else {
tmp_name[0]='\0';
snprintf(tmp_name, sizeof(tmp_name), "Babel %d", trail_count);
char route_reversed=0;
/* route name */
+#if NEW_STRINGS
+// This whole function needs to be replaced...
+ if (!rte->rte_name.isEmpty()) {
+ name = xstrdup(rte->rte_name);
+ } else if (!rte->rte_desc.isEmpty()) {
+ name = xstrdup(rte->rte_desc);
+#else
if (rte->rte_name) {
name = xstrdup(rte->rte_name);
} else if (rte->rte_desc) {
name = xstrdup(rte->rte_desc);
+#endif
} else {
tmp_name[0]='\0';
snprintf(tmp_name, sizeof(tmp_name), "Babel R%d", ++lowrance_route_count);
char* name, tmp_name[20];
if (++trail_count == 1) {
+#if NEW_STRINGS
+ if (!trk->rte_name.isEmpty()) {
+ name = xstrdup(trk->rte_name);
+ } else if (!trk->rte_desc.isEmpty()) {
+ name = xstrdup(trk->rte_desc);
+#else
if (trk->rte_name) {
name = xstrdup(trk->rte_name);
} else if (trk->rte_desc) {
name = xstrdup(trk->rte_desc);
+#endif
} else {
tmp_name[0]='\0';
snprintf(tmp_name, sizeof(tmp_name), "Babel %d", trail_count);
double ilon, ilat;
double lon, lat;
int lon_deg, lat_deg;
- char* shortname;
- char* cname = NULL;
const char* ctype = NULL;
QString placer;
ilat = waypointp->latitude;
ilon = waypointp->longitude;
- shortname = waypointp->shortname;
lon = fabs(ilon);
lat = fabs(ilat);
}
QString placeddate = maggeo_fmtdate(waypointp->creation_time);
QString lfounddate = maggeo_fmtdate(waypointp->gc_data->last_found);
- cname = mkshort(desc_handle,
+ QString cname = mkshort(desc_handle,
+#if NEW_STRINGS
+ waypointp->notes.isEmpty() ? waypointp->description : waypointp->notes);
+#else
waypointp->notes ? waypointp->notes : waypointp->description);
+#endif
placer = waypointp->gc_data->placer;
/*
lon, ilon < 0 ? 'W' : 'E',
waypointp->altitude == unknown_alt ?
0 : waypointp->altitude);
- append(obuf, shortname);
- append(obuf, cname);
+ append(obuf, CSTRc(waypointp->shortname));
+ append(obuf, CSTR(cname));
append(obuf, placer.toUtf8().data());
append(obuf, waypointp->gc_data->hint.toUtf8().data());
append(obuf, ctype);
strcat(obuf, ",");
}
- if (cname) {
- xfree(cname);
- }
-
maggeo_writemsg(obuf);
}
/* These tracks don't have names, so derive one
* from input filename.
*/
- char* e;
- const char* s = get_filename(curfname);
trk_head = route_head_alloc();
/* Whack trailing extension if present. */
+#if NEW_STRINGS
+ QString s = get_filename(curfname);
+ int idx = s.indexOf('.');
+ if (idx > 0) {
+ s.truncate(idx);
+ }
+
+ trk_head->rte_name = s;
+#else
+ char* e;
+ const char* s = get_filename(curfname);
trk_head->rte_name = xstrdup(s);
e = strrchr(trk_head->rte_name, '.');
if (e) {
*e = '\0';
}
-
+#endif
track_add_head(trk_head);
}
*/
QUEUE_FOR_EACH(&rte_wpt_tmp, welem, wtmp) {
waypt = (waypoint*)welem;
+#if NEW_STRINGS
+ if (waypt->shortname == re->wpt_name) {
+#else
if (strcmp(waypt->shortname, re->wpt_name) == 0) {
+#endif
waypoint* wpt = waypt_dupe(waypt);
route_add_wpt(rte_head, wpt);
break;
char obuf[200];
char ofmtdesc[200];
QString icon_token;
- char* owpt;
- char* odesc;
ilat = waypointp->latitude;
ilon = waypointp->longitude;
if (get_cache_icon(waypointp)) {
icon_token = mag_find_token_from_descr(get_cache_icon(waypointp));
}
-
+#if NEW_STRINGS
+ QString isrc = waypointp->notes.isEmpty() ? waypointp->description : waypointp->notes;
+ QString owpt = global_opts.synthesize_shortnames ?
+ mkshort_from_wpt(mkshort_handle, waypointp) : waypointp->shortname;
+ QString odesc = isrc;
+#else
String isrc = waypointp->notes ? waypointp->notes : waypointp->description;
- owpt = global_opts.synthesize_shortnames ?
+ char* owpt = global_opts.synthesize_shortnames ?
mkshort_from_wpt(mkshort_handle, waypointp) : waypointp->shortname;
- odesc = isrc ? isrc : (char*)"";
- owpt = mag_cleanse(owpt);
+ char* odesc = isrc ? isrc : (char*)"";
+#endif
+ owpt = mag_cleanse(CSTRc(owpt));
if (global_opts.smart_icons &&
waypointp->gc_data->diff && waypointp->gc_data->terr) {
sprintf(ofmtdesc, "%d/%d %s", waypointp->gc_data->diff,
- waypointp->gc_data->terr, odesc);
+ waypointp->gc_data->terr, CSTRc(odesc));
odesc = mag_cleanse(ofmtdesc);
} else {
- odesc = mag_cleanse(odesc);
+ odesc = mag_cleanse(CSTRc(odesc));
}
/*
* to deliver turn-by-turn popups for street routing) allow a
* cap on the comments delivered so we leave space for it to route.
*/
+#if NEW_STRINGS
+ if (!odesc.isEmpty() && (wptcmtcnt++ >= wptcmtcnt_max)) {
+#else
if (odesc && /* !is_file && */ (wptcmtcnt++ >= wptcmtcnt_max)) {
+#endif
odesc[0] = 0;
}
waypointp->altitude == unknown_alt ?
0 : waypointp->altitude,
wpt_len,
- owpt,
- odesc,
+ CSTRc(owpt),
+ CSTRc(odesc),
icon_token.toUtf8().data());
mag_writemsg(obuf);
+#if NEW_STRINGS
+#else
xfree(owpt);
xfree(odesc);
+#endif
if (!is_file) {
if (mag_error) {
} else {
pbuff = buff2;
}
-
+#if NEW_STRINGS
+// TODO: figure out what this code is trying to do.
+ sprintf(pbuff, "%s,%s", CSTR(waypointp->shortname), icon_token.toUtf8().data());
+#else
owpt = waypointp->shortname;
if (strlen(owpt) > sizeof(buff1) - 3) {
owpt[sizeof(buff1) - 3] = 0;
sprintf(pbuff, "%s,%s", owpt, icon_token.toUtf8().data());
xfree(owpt);
+#endif
if ((tmp == &rte->waypoint_list) || ((i % 2) == 0)) {
char expbuf[1024];
expbuf[0] = 0;
if (explorist) {
snprintf(expbuf, sizeof(expbuf), "%s,",
+#if NEW_STRINGS
+ CSTRc(rte->rte_name));
+#else
rte->rte_name ? CSTRc(rte->rte_name) : "");
+#endif
}
+
sprintf(obuff, "PMGNRTE,%d,%d,c,%d,%s%s,%s",
numlines, thisline,
rte->rte_num ? rte->rte_num : route_out_count,
unsigned int c = 0;
double falt;
static int cnt = 0;
- const char* sn = global_opts.synthesize_shortnames ?
+ QString sn = global_opts.synthesize_shortnames ?
mkshort_from_wpt(mkshort_handle, waypointp) :
waypointp->shortname;
- char* tmp;
+ QString tmp;
/*
* The format spec doesn't call out the character set of waypoint
tmp = mkshort(wpt_handle, sn);
gbfputpstr(tmp, mapsend_file_out);
- if (tmp) {
- xfree(tmp);
- }
+#if NEW_STRINGS
+ c = waypointp->description.length();
+ if (c > 30) {
+ c = 30;
+ }
+ gbfputc(c, mapsend_file_out);
+ gbfwrite(CSTR(waypointp->description), 1, c, mapsend_file_out);
+#else
tmp = waypointp->description;
if (tmp) {
c = strlen(tmp);
}
gbfputc(c, mapsend_file_out);
gbfwrite(tmp, 1, c, mapsend_file_out);
+#endif
/* #, icon, status */
gbfputint32(++cnt, mapsend_file_out);
route_wp_count++;
/* waypoint name */
+#if NEW_STRINGS
+ c = waypointp->shortname.length();
+#else
c = waypointp->shortname ? strlen(waypointp->shortname) : 0;
+#endif
gbfwrite(&c, 1, 1, mapsend_file_out);
- gbfwrite(waypointp->shortname, 1, c, mapsend_file_out);
+ gbfwrite(CSTRc(waypointp->shortname), 1, c, mapsend_file_out);
/* waypoint number */
gbfputint32(route_wp_count, mapsend_file_out);
*/
const char* verstring = "30";
queue* elem, *tmp;
- char* tname;
int i;
mapsend_hdr hdr = {13, {'4','D','5','3','3','3','3','4',' ','M','S'},
{'3','0'}, ms_type_track, {0, 0, 0}
hdr.ms_version[1] = verstring[1];
gbfwrite(&hdr, sizeof(hdr), 1, mapsend_file_out);
-
+#if NEW_STRINGS
+ QString tname = trk->rte_name.isEmpty() ? "Track" : trk->rte_name;
+ gbfputpstr(tname, mapsend_file_out);
+#else
/* track name */
+ char* tname;
if (!trk->rte_name) {
tname = xstrdup("Track");
} else {
gbfputpstr(tname, mapsend_file_out);
xfree(tname);
+#endif
/* total nodes (waypoints) this track */
i = 0;
*
*/
waypoint*
-mps_find_wpt_q_by_name(const queue* whichQueue, const char* name)
+mps_find_wpt_q_by_name(const queue* whichQueue, const QString& name)
{
queue* elem, *tmp;
waypoint* waypointp;
QUEUE_FOR_EACH(whichQueue, elem, tmp) {
waypointp = (waypoint*) elem;
- if (0 == strcmp(waypointp->shortname, name)) {
+ if (waypointp->shortname == name) {
return waypointp;
}
}
int reclen;
int lat, lon;
int icon;
- const char* src = ""; /* default to empty string */
- char* ident;
char* ascii_description;
char zbuf[25];
char ffbuf[25];
if (WAYPT_HAS(wpt, depth) && mpsusedepth) {
mps_depth = wpt->depth;
}
-
+ QString src;
+#if NEW_STRINGS
+ if (!wpt->description.isEmpty()) {
+ src = wpt->description;
+ }
+ if (!wpt->notes.isEmpty()) {
+ src = wpt->notes;
+ }
+#else
if (wpt->description) {
src = wpt->description;
}
if (wpt->notes) {
src = wpt->notes;
}
- ident = global_opts.synthesize_shortnames ?
+#endif
+ QString ident = global_opts.synthesize_shortnames ?
mkshort(mkshort_handle, src) :
- wpt->shortname;
+ CSTRc(wpt->shortname);
memset(zbuf, 0, sizeof(zbuf));
memset(ffbuf, 0xff, sizeof(ffbuf));
icon = mps_converted_icon_number(icon, mps_ver, MAPSOURCE);
/* two NULL (0x0) bytes at end of each string */
+#if NEW_STRINGS
+ ascii_description = xstrdup(wpt->description);
+#else
ascii_description = wpt->description ? xstrdup(wpt->description) : xstrdup("");
- reclen = strlen(ident) + strlen(ascii_description) + 2;
+#endif
+ reclen = ident.length() + strlen(ascii_description) + 2;
if ((mps_ver == 4) || (mps_ver == 5)) {
/* v4.06 & V5.0*/
reclen += 85; /* "W" (1) + strlen(name) + NULL (1) + class(4) + country(sz) +
+ NULL (1) + prox(9) + display(4) + colour(4) + symbol(4) + city(sz) +
state(sz) + facility(sz) + unknown2(1) + depth(9) + unknown3(7) */
/* -1 as reclen is interpreted from zero meaning a reclength of one */
+#if NEW_STRINGS
+ if (!wpt->notes.isEmpty()) {
+#else
if (wpt->notes) {
- reclen += strlen(wpt->notes);
+#endif
+ reclen += strlen(CSTRc(wpt->notes));
}
} else {
/* v3.02 */
gbfputc(1, mps_file);
gbfputdbl(mps_altitude, mps_file);
}
+#if NEW_STRINGS
+ if (!wpt->description.isEmpty()) {
+#else
if (wpt->description) {
+#endif
gbfputs(ascii_description, mps_file);
}
gbfwrite(zbuf, 1, 1, mps_file); /* NULL termination */
gbfwrite(zbuf, 2, 1, mps_file); /* unknown */
if ((mps_ver == 4) || (mps_ver == 5)) {
gbfwrite(zbuf, 4, 1, mps_file); /* unknown */
+#if NEW_STRINGS
+ if (!wpt->notes.isEmpty()) {
+#else
if (wpt->notes) {
+#endif
gbfputs(wpt->notes, mps_file);
}
gbfwrite(zbuf, 1, 1, mps_file); /* string termination */
waypoint* wptfound = NULL;
/* Search for this waypoint in the ones already written */
- wptfound = mps_find_wpt_q_by_name(&written_wpt_head, wpt->shortname);
+ wptfound = mps_find_wpt_q_by_name(&written_wpt_head, CSTRc(wpt->shortname));
/* is the next line necessary? Assumes we know who's called us and in what order */
if (wptfound == NULL) {
- wptfound = mps_find_wpt_q_by_name(&written_route_wpt_head, wpt->shortname);
+ wptfound = mps_find_wpt_q_by_name(&written_route_wpt_head, CSTRc(wpt->shortname));
}
/* if this waypoint hasn't been written then it is okay to do so */
waypoint* wptfound = NULL;
/* Search for this waypoint in the ones already written */
- wptfound = mps_find_wpt_q_by_name(&written_wpt_head, wpt->shortname);
+ wptfound = mps_find_wpt_q_by_name(&written_wpt_head, CSTRc(wpt->shortname));
if (wptfound == NULL)
/* so, not a real wpt, so must check route wpts already written as reals */
{
- wptfound = mps_find_wpt_q_by_name(&written_route_wpt_head, wpt->shortname);
+ wptfound = mps_find_wpt_q_by_name(&written_route_wpt_head, CSTRc(wpt->shortname));
}
/* if this waypoint hasn't been written then it is okay to do so
char* rname;
char hdr[20];
char zbuf[20];
- const char* src = "";
- char* ident;
waypoint* testwpt;
time_t uniqueValue = 0;
}
}
+ QString src;
+#if NEW_STRINGS
+ if (!testwpt->description.isEmpty()) {
+#else
if (testwpt->description) {
+#endif
src = testwpt->description;
}
+#if NEW_STRINGS
+ if (!testwpt->notes.isEmpty()) {
+#else
if (testwpt->notes) {
+#endif
src = testwpt->notes;
}
- ident = global_opts.synthesize_shortnames ?
+ QString ident = global_opts.synthesize_shortnames ?
mkshort(mkshort_handle, src) :
- testwpt->shortname;
- allWptNameLengths += strlen(ident) + 1;
+ CSTRc(testwpt->shortname);
+ allWptNameLengths += ident.length() + 1;
rte_datapoints++;
}
}
/* route name */
+#if NEW_STRINGS
+ if (rte->rte_name.isEmpty()) {
+#else
if (!rte->rte_name) {
+#endif
sprintf(hdr, "Route%04x", (unsigned) uniqueValue);
rname = xstrdup(hdr);
} else {
int lon;
char zbuf[20];
char ffbuf[20];
- const char* src = "";
- char* ident;
int reclen;
int maxlat;
}
+ QString src;
+#if NEW_STRINGS
+ if (!rtewpt->description.isEmpty()) {
+ src = rtewpt->description;
+ }
+ if (!rtewpt->notes.isEmpty()) {
+ src = rtewpt->notes;
+ }
+#else
if (rtewpt->description) {
src = rtewpt->description;
}
if (rtewpt->notes) {
src = rtewpt->notes;
}
- ident = global_opts.synthesize_shortnames ?
+#endif
+ QString ident = global_opts.synthesize_shortnames ?
mkshort(mkshort_handle, src) :
- rtewpt->shortname;
+ CSTRc(rtewpt->shortname);
gbfputs(ident, mps_file);
gbfwrite(zbuf, 1, 1, mps_file); /* NULL termination to ident */
}
/* track name */
+#if NEW_STRINGS
+ if (trk->rte_name.isEmpty()) {
+#else
if (!trk->rte_name) {
+#endif
sprintf(hdr, "Track%04x", (unsigned) uniqueValue);
tname = xstrdup(hdr);
} else {
* As above, but arg list is a waypoint so we can centralize
* the code that considers the alternate sources.
*/
-char*
+String
mkshort_from_wpt(short_handle h, const waypoint* wpt)
{
/* This probably came from a Groundspeak Pocket Query
* more stuff than should be in any one field...
*/
if (wpt->gc_data->diff && wpt->gc_data->terr &&
+#if NEW_STRINGS
+ !wpt->notes.isEmpty()) {
+#else
wpt->notes && wpt->notes[0]) {
+#endif
return mkshort(h, wpt->notes);
}
+#if NEW_STRINGS
+ if (!wpt->description.isEmpty()) {
+#else
if (wpt->description) {
+#endif
return mkshort(h, wpt->description);
}
+#if NEW_STRINGS
+ if (!wpt->notes.isEmpty()) {
+#else
if (wpt->notes) {
+#endif
return mkshort(h, wpt->notes);
}
data->name, data->visible ? "yes" : "NO", data->objid));
data->data = wpt = waypt_new();
+#if NEW_STRINGS
+ wpt->shortname = QString::fromLatin1(data->name);
+#else
wpt->shortname = xstrdup(data->name);
-
+#endif
time = data->mtime;
if (! time) {
time = data->ctime;
}
if (*cend++) {
+#if NEW_STRINGS
+ wpt->notes = QString::fromLatin1(cend);
+#else
wpt->notes = xstrdup(cend);
+#endif
}
if (wpt->HasUrlLink()) {
wpt->notes = xstrdup(str);
}
xfree(str);
-
+#if NEW_STRINGS
+ if (!wpt->notes.isEmpty()) {
+#else
if (wpt->notes) {
- DBG((sobj, "notes = \"%s\"\n", wpt->notes));
+#endif
+ DBG((sobj, "notes = \"%s\"\n", CSTRc(wpt->notes)));
}
mmo_fillbuf(buf, 12, 1);
wpt->latitude = wpt2->latitude;
wpt->longitude = wpt2->longitude;
+#if NEW_STRINGS
+ wpt->shortname = wpt2->shortname;
+ wpt->description = wpt2->description;
+ wpt->notes = wpt2->notes;
+#else
xfree(wpt->shortname);
wpt->shortname = xstrdup(wpt2->shortname);
-
if (wpt2->description) {
wpt->description = xstrdup(wpt2->description);
}
if (wpt2->notes) {
wpt->notes = xstrdup(wpt2->notes);
}
+#endif
if (wpt2->HasUrlLink()) {
UrlLink l = wpt2->GetUrlLink();
wpt->notes = xstrdup(l.url_.toUtf8().data());
static void
mmo_write_wpt_cb(const waypoint* wpt)
{
- char* str, *cx;
+ char* str;
int objid;
time_t time;
int icon = 0;
DBG(("write", "waypoint \"%s\"\n", wpt->shortname ? wpt->shortname : "Mark"));
objid = mmo_write_obj_head("CObjWaypoint",
+#if NEW_STRINGS
+ wpt->shortname.isEmpty() ? "Mark" : CSTRc(wpt->shortname), time, obj_type_wpt);
+#else
(wpt->shortname && *wpt->shortname) ? CSTRc(wpt->shortname) : "Mark", time, obj_type_wpt);
+#endif
data = mmo_register_object(objid, wpt, wptdata);
data->refct = 1;
mmo_write_category("CCategory", (mmo_datatype == rtedata) ? "Waypoints" : "Marks");
str = xstrdup("");
}
- cx = wpt->notes;
+ QString cx = wpt->notes;
if (cx == NULL) {
cx = wpt->description;
}
tmp.is_html = 1;
cx = kml = strip_html(&tmp);
}
- str = xstrappend(str, cx);
+ str = xstrappend(str, CSTR(cx));
if (kml) {
xfree(kml);
}
}
objid = mmo_write_obj_head("CObjRoute",
+#if NEW_STRINGS
+ rte->rte_name.isEmpty() ? "Route" : CSTRc(rte->rte_name), time, obj_type_rte);
+#else
(rte->rte_name && *rte->rte_name) ? CSTRc(rte->rte_name) : "Route", time, obj_type_rte);
+#endif
mmo_register_object(objid, rte, rtedata);
mmo_write_category("CCategory", "Route");
gbfputc(0, fout); /* unknown */
}
objid = mmo_write_obj_head("CObjTrack",
+#if NEW_STRINGS
+ trk->rte_name.isEmpty() ? "Track" : CSTRc(trk->rte_name), gpsbabel_time, obj_type_trk);
+#else
(trk->rte_name && *trk->rte_name) ? CSTRc(trk->rte_name) : "Track", gpsbabel_time, obj_type_trk);
+#endif
mmo_write_category("CCategory", "Track");
gbfputuint16(trk->rte_waypt_ct, fout);
track_disp_all(mmo_write_trk_head_cb, mmo_write_trk_tail_cb, mmo_write_wpt_cb);
}
-/**************************************************************************/
ff_vecs_t mmo_vecs = {
ff_type_file,
CET_CHARSET_MS_ANSI, 0
};
-
-/**************************************************************************/
#include "jeeps/gpsmath.h"
#include <ctype.h>
#include <math.h>
+#include <QtCore/QDebug>
+#include <QtCore/QTextCodec>
#define MYNAME "Naviguide"
static void
data_read(void)
{
- int n;
- unsigned i;
- waypoint* wpt_tmp;
-
if (process_rte) {
rte_head = route_head_alloc();
route_add_head(rte_head);
}
- for (n = 0; n < nof_wp; ++n) {
+ QTextCodec* codec = QTextCodec::codecForName("Hebrew");
+ if (!codec) {
+ fatal(MYNAME ": Unable to locate codec for Hebrew");
+ }
+
+ for (int n = 0; n < nof_wp; ++n) {
- wpt_tmp = waypt_new();
+ waypoint* wpt_tmp = waypt_new();
/* Read waypoint data */
}
/* Clear commas form the comment for CSV file commonality */
- for (i = 0; i <strlen(strComment); ++i) {
+ for (unsigned i = 0; i <strlen(strComment); ++i) {
if (strComment[i] == ',') {
strComment[i] = ' ';
}
/* put the data in the waypoint structure */
ng_convert_datum(wpt_tmp);
-
+#if NEW_STRINGS
+ wpt_tmp->shortname = codec->toUnicode(WPNC.strName);
+ wpt_tmp->description = codec->toUnicode(strComment);
+#else
wpt_tmp->shortname = xstrdup(WPNC.strName);
wpt_tmp->description = xstrdup(strComment);
+#endif
if (process_rte) {
route_add_wpt(rte_head, wpt_tmp);
return waypt1->latitude == waypt2->latitude &&
waypt1->longitude == waypt2->longitude &&
waypt1->altitude == waypt2->altitude &&
+#if NEW_STRINGS
+ waypt1->shortname == waypt2->shortname;
+#else
strcmp(waypt1->shortname, waypt2->shortname) == 0;
+#endif
}
unsigned
buffer[0] = 0x00;
buffer[1] = 0x40;
le_write16(buffer + 2, 0);
- strncpy((char*)buffer + 4, waypt->shortname, 6);
+ strncpy((char*)buffer + 4, CSTRc(waypt->shortname), 6);
buffer[10] = 0;
buffer[11] = 0;
encode_position(waypt, buffer + 12);
serial_write_route_end(const route_head* route)
{
unsigned char* data;
- unsigned src;
- unsigned sr;
+ unsigned src;
+ unsigned sr;
unsigned char id[1];
- const char* rte_name;
+ QString rte_name;
rte_name = route->rte_name;
if (rte_name == NULL) {
data[2] = 0;
data[3] = 0x20;
memset(data + 4, 0, 14);
- strncpy((char*)data + 4, rte_name, 13);
+ strncpy((char*)data + 4, CSTR(rte_name), 13);
data[18] = 0;
data[19] = 0;
le_write32(data + 20, 0);
waypoint* wpt_a = ((const htable_t*)a)->wpt;
waypoint* wpt_b = ((const htable_t*)b)->wpt;
-
+#if NEW_STRINGS
+ return wpt_a->description.compare(wpt_b->description);
+#else
return strcmp(wpt_a->description, wpt_b->description);
+#endif
}
}
{
int i, ct = waypt_count(), serial = 0;
htable_t* htable, *bh;
- const char* snptr;
- char* tmp_sn;
unsigned long last_crc;
char ssid[32 + 5 + 1];
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
bh->wpt = (waypoint*) elem;
#endif
- snptr = bh->wpt->shortname;
- tmp_sn = strlower(xstrdup(snptr));
- bh->crc = get_crc32(tmp_sn, strlen(snptr));
- xfree(tmp_sn);
+ QString snptr = bh->wpt->shortname;
+ QString tmp_sn = snptr.toLower();
+ bh->crc = get_crc32(CSTR(tmp_sn), tmp_sn.length());
i ++;
bh ++;
}
for (i = 0, bh = htable; i < ct; i++, bh++) {
if (last_crc == bh->crc) {
+#if NEW_STRINGS
+ bh->wpt->shortname += QString("/%1").arg(++serial);
+#else
snprintf(ssid, sizeof ssid, "%s/%d", CSTRc(bh->wpt->shortname), ++serial);
xfree(bh->wpt->shortname);
bh->wpt->shortname = xstrdup(ssid);
+#endif
} else {
last_crc = bh->crc;
}
if (!wpt) {
return;
}
+#if NEW_STRINGS
+ wpt->shortname = "Position";
+#else
if (wpt->shortname) {
xfree(wpt->shortname);
}
wpt->shortname = xstrdup("Position");
+#endif
nmea_add_wpt(wpt, NULL);
return;
}
{
char obuf[200];
double lat,lon;
- char* s;
+ String s;
int cksum;
lat = degrees2ddmm(wpt->latitude);
snprintf(obuf, sizeof(obuf), "GPWPL,%08.3f,%c,%09.3f,%c,%s",
fabs(lat), lat < 0 ? 'S' : 'N',
- fabs(lon), lon < 0 ? 'W' : 'E', s
+ fabs(lon), lon < 0 ? 'W' : 'E', CSTRc(s)
);
cksum = nmea_cksum(obuf);
gbfflush(file_out);
gb_sleep(sleepus);
}
-
+#if NEW_STRINGS
+#else
xfree(s);
+#endif
}
str = osm_strip_html(value);
if (strcmp(key, "name") == 0) {
+#if NEW_STRINGS
+ if (wpt->shortname.isEmpty()) {
+ wpt->shortname = str;
+ }
+#else
if (! wpt->shortname) {
wpt->shortname = xstrdup(str);
}
+#endif
} else if (strcmp(key, "name:en") == 0) {
+#if NEW_STRINGS
+ wpt->shortname = str;
+#else
if (wpt->shortname) {
xfree(wpt->shortname);
}
wpt->shortname = xstrdup(str);
+#endif
} else if ((ikey = osm_feature_ikey(key)) >= 0) {
char* id = osm_feature_symbol(ikey, value);
wpt->icon_descr = id;
xfree(id);
}
} else if (strcmp(key, "note") == 0) {
+#if NEW_STRINGS
+ if (wpt->notes.isEmpty()) {
+ wpt->notes = str;
+ } else {
+ wpt->notes += "; ";
+ wpt->notes += str;
+ }
+#else
if (wpt->notes) {
char* tmp;
xasprintf(&tmp, "%s; %s", CSTRc(wpt->notes), str);
} else {
wpt->notes = xstrdup(str);
}
+#endif
} else if (strcmp(key, "gps:hdop") == 0) {
wpt->hdop = atof(str);
} else if (strcmp(key, "gps:vdop") == 0) {
str = osm_strip_html(value);
if (strcmp(key, "name") == 0) {
+#if NEW_STRINGS
+ if (rte->rte_name.isEmpty()) {
+ rte->rte_name = str;
+ }
+#else
if (! rte->rte_name) {
rte->rte_name = xstrdup(str);
}
+#endif
} else if (strcmp(key, "name:en") == 0) {
+#if NEW_STRINGS
+ rte->rte_name = str;
+#else
if (rte->rte_name) {
xfree(rte->rte_name);
}
rte->rte_name = xstrdup(str);
+#endif
}
xfree(str);
}
static void
-osm_write_tag(const char* key, const char* value)
+osm_write_tag(const QString& key, const QString& value)
{
- if (value && *value) {
- char* str = xml_entitize(value);
- gbfprintf(fout, " <tag k='%s' v='%s'/>\n", key, str);
+ if (!value.isEmpty()) {
+ char* str = xml_entitize(CSTR(value));
+ gbfprintf(fout, " <tag k='%s' v='%s'/>\n", CSTR(key), str);
xfree(str);
}
}
osm_name_from_wpt(const waypoint* wpt)
{
QString name = QString("%1\01%2\01%3")
+#if NEW_STRINGS
+ .arg(wpt->shortname)
+#else
.arg((wpt->shortname) ? CSTRc(wpt->shortname) : "")
+#endif
.arg(wpt->latitude)
.arg(wpt->longitude);
return name;
}
osm_write_tag("name", wpt->shortname);
+#if NEW_STRINGS
+ osm_write_tag("note", (wpt->notes.isEmpty()) ? wpt->description : wpt->notes);
+#else
osm_write_tag("note", (wpt->notes) ? wpt->notes : wpt->description);
+#endif
if (!wpt->icon_descr.isNull()) {
osm_disp_feature(wpt);
}
route_head* route;
route = (route_head*) hd;
+#if NEW_STRINGS
+ grp = route->rte_name.toInt();
+#else
grp = atoi(route->rte_name);
+#endif
i = 0;
while (i<groups_cnt && groups[i].group!=grp) {
i++;
} else {
strcpy(name,groups[i].name);
}
+#if NEW_STRINGS
+ route->rte_name = name;
+#else
route->rte_name = (char*) xrealloc(route->rte_name,(strlen(name)+1)*sizeof(char));
strcpy(route->rte_name,name);
+#endif
}
static void ovl_read(void)
govl_group_cnt++;
}
-static void symbol_text(double east,double north,char* text,int group)
+static void symbol_text(double east,double north,const QString& text,int group)
{
gbfprintf(fpout,"[Symbol %d]\n",govl_symbol_cnt+1);
gbfprintf(fpout,"Typ=2\n"); // Text
gbfprintf(fpout,"Dir=%d\n",100+((int) govl_dir));
gbfprintf(fpout,"XKoord=%.8lf\n",east); // precision 8 = better than 1mm
gbfprintf(fpout,"YKoord=%.8lf\n",north);
- gbfprintf(fpout,"Text=%s\n",text);
+ gbfprintf(fpout,"Text=%s\n",CSTR(text));
govl_symbol_cnt++;
}
static void overlay_waypt_pr(const waypoint* waypointp)
{
const char* oname;
- char* odesc;
/*
* Desparation time, try very hard to get a good shortname
*/
- odesc = waypointp->notes;
- if (!odesc) {
+ QString odesc = waypointp->notes;
+ if (odesc.isEmpty()) {
odesc = waypointp->description;
}
- if (!odesc) {
+ if (odesc.isEmpty()) {
odesc = waypointp->shortname;
}
oname = global_opts.synthesize_shortnames ?
- mkshort(mkshort_handle, odesc) :
- waypointp->shortname;
+ mkshort(mkshort_handle, CSTR(odesc)) :
+ CSTRc(waypointp->shortname);
gbfprintf(fpout,"[Symbol %d]\n",govl_symbol_cnt+1);
gbfprintf(fpout,"Typ=1\n");
ozi_openfile(ozi_ofname);
gbfprintf(file_out, ozi_trk_header,
altunit == 'f' ? "Feet" : "Meters",
+#if NEW_STRINGS
+ rte->rte_name.isEmpty() ? "ComplimentsOfGPSBabel" : CSTRc(rte->rte_name));
+#else
rte->rte_name ? CSTRc(rte->rte_name) : "ComplimentsOfGPSBabel");
+#endif
}
track_out_count++;
gbfprintf(file_out, "R,%d,%s,%s,\r\n",
route_out_count,
+#if NEW_STRINGS
+ CSTRc(rte->rte_name),
+ CSTRc(rte->rte_desc));
+#else
rte->rte_name ? CSTRc(rte->rte_name) : "",
rte->rte_desc ? CSTRc(rte->rte_desc) : "");
-
+#endif
}
static void
gbfprintf(file_out, "W,%d,,%d,%s,%.6f,%.6f,%s,0,1,3,0,65535,%s,0,0\r\n",
route_out_count,
route_wpt_count,
+#if NEW_STRINGS
+ CSTR(waypointp->shortname),
+#else
waypointp->shortname ? CSTRc(waypointp->shortname) : "",
+#endif
waypointp->latitude,
waypointp->longitude,
ozi_time,
+#if NEW_STRINGS
+ CSTR(waypointp->description));
+#else
waypointp->description ? CSTRc(waypointp->description) : "");
+#endif
}
static int index = 0;
double alt;
char ozi_time[16];
+#if NEW_STRINGS
+ QString description;
+ QString shortname;
+#else
char* description;
char* shortname;
+#endif
int faked_fsdata = 0;
ozi_fsdata* fs = NULL;
int icon = 0;
} else {
alt = wpt->altitude * alt_scale;
}
-
+#if NEW_STRINGS
+ if ((wpt->shortname.isEmpty()) || (global_opts.synthesize_shortnames)) {
+ if (!wpt->description.isEmpty()) {
+#else
if ((!wpt->shortname) || (global_opts.synthesize_shortnames)) {
if (wpt->description) {
+#endif
if (global_opts.synthesize_shortnames) {
shortname = mkshort_from_wpt(mkshort_handle, wpt);
} else {
} else {
shortname = csv_stringclean(wpt->shortname, BADCHARS);
}
-
+#if NEW_STRINGS
+ if (wpt->description.isEmpty()) {
+ if (!shortname.isEmpty()) {
+#else
if (!wpt->description) {
if (shortname) {
+#endif
description = csv_stringclean(shortname, BADCHARS);
} else {
description = xstrdup("");
gbfprintf(file_out,
"%d,%s,%.6f,%.6f,%s,%d,%d,%d,%d,%d,%s,%d,%d,",
- index, shortname, wpt->latitude, wpt->longitude, ozi_time, icon,
- 1, 3, fs->fgcolor, fs->bgcolor, description, 0, 0);
+ index, CSTRc(shortname), wpt->latitude, wpt->longitude, ozi_time, icon,
+ 1, 3, fs->fgcolor, fs->bgcolor, CSTRc(description), 0, 0);
if (WAYPT_HAS(wpt, proximity) && (wpt->proximity > 0)) {
gbfprintf(file_out, "%.1f,", wpt->proximity * prox_scale);
} else if (proximity > 0) {
gbfprintf(file_out,"%d,", 0);
}
gbfprintf(file_out, "%.0f,%d,%d,%d\r\n", alt, 6, 0, 17);
-
+#if NEW_STRINGS
+#else
xfree(description);
xfree(shortname);
+#endif
if (faked_fsdata) {
xfree(fs);
gbfprintf(file_out, "W %-6.6s %c%08.5f %c%011.5f %s %5.f %-40.40s %5e %d\n",
global_opts.synthesize_shortnames ?
- mkshort_from_wpt(mkshort_handle, wpt) :
+ CSTRc(mkshort_from_wpt(mkshort_handle, wpt)) :
CSTRc(wpt->shortname),
lat < 0.0 ? 'S' : 'N',
fabs(lat),
static void
pcx_track_hdr(const route_head* trk)
{
- char* name;
char buff[20];
route_ctr++;
snprintf(buff, sizeof(buff)-1, "Trk%03d", route_ctr);
- name = mkshort(mkshort_handle2, (trk->rte_name != NULL) ? trk->rte_name : buff);
+ QString name = mkshort(mkshort_handle2, (trk->rte_name != NULL) ? trk->rte_name : buff);
/* Carto Exploreur (popular in France) chokes on trackname headers,
* so provide option to supppress these.
*/
if (!cartoexploreur) {
- gbfprintf(file_out, "\n\nH TN %s\n", name);
+ gbfprintf(file_out, "\n\nH TN %s\n", CSTR(name));
}
- xfree(name);
gbfprintf(file_out, "H LATITUDE LONGITUDE DATE TIME ALT ;track\n");
}
static void
pcx_route_hdr(const route_head* rte)
{
- char* name;
char buff[20];
route_ctr++;
snprintf(buff, sizeof(buff)-1, "Rte%03d", route_ctr);
- name = mkshort(mkshort_handle2, (rte->rte_name != NULL) ? rte->rte_name : buff);
+ QString name = mkshort(mkshort_handle2, (rte->rte_name != NULL) ? rte->rte_name : buff);
/* see pcx_track_hdr */
if (!cartoexploreur) {
- gbfprintf(file_out, "\n\nR %s\n", name);
+ gbfprintf(file_out, "\n\nR %s\n", CSTR(name));
}
- xfree(name);
gbfprintf(file_out, "\n"
"H IDNT LATITUDE LONGITUDE DATE TIME ALT DESCRIPTION PROXIMITY SYMBOL ;waypts\n");
}
if (head != NULL) {
route->rte_name = xstrdup(head->shortname);
}
+#if NEW_STRINGS
+ route->rte_name += " - ";
+#else
route->rte_name = xstrappend(route->rte_name, " - ");
+#endif
if (tail != NULL) {
+#if NEW_STRINGS
+ route->rte_name += tail->shortname;
+#else
route->rte_name = xstrappend(route->rte_name, tail->shortname);
+#endif
tail->altitude = dest_altitude;
}
}
void wpt_from_lat(xg_string args, const QXmlStreamAttributes* unused)
{
if (wpt_from != NULL) {
+#if NEW_STRINGS
+ wpt_from->latitude = args.toDouble();
+#else
wpt_from->latitude = atof(args);
+#endif
}
}
void wpt_from_lon(xg_string args, const QXmlStreamAttributes* unused)
{
if (wpt_from != NULL) {
+#if NEW_STRINGS
+ wpt_from->longitude = args.toDouble();
+#else
wpt_from->longitude = atof(args);
+#endif
}
}
void wpt_from_name(xg_string args, const QXmlStreamAttributes* unused)
{
if (wpt_from != NULL) {
+#if NEW_STRINGS
+ wpt_from->shortname += args;
+#else
wpt_from->shortname = xstrappend(wpt_from->shortname, args);
+#endif
}
}
void wpt_from_elev(xg_string args, const QXmlStreamAttributes* unused)
{
if (wpt_from != NULL) {
+#if NEW_STRINGS
+ wpt_from->altitude = FEET_TO_METERS(args.toDouble());
+#else
wpt_from->altitude = FEET_TO_METERS(atof(args));
+#endif
}
}
void wpt_to_lat(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_to->latitude = args.toDouble();
+#else
wpt_to->latitude = atof(args);
+#endif
}
void wpt_to_lon(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_to->longitude = args.toDouble();
+#else
wpt_to->longitude = atof(args);
+#endif
}
void wpt_to_name(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_to->shortname += args;
+#else
wpt_to->shortname = xstrappend(wpt_to->shortname, args);
+#endif
}
void wpt_to_elev(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ dest_altitude = FEET_TO_METERS(args.toDouble());
+#else
dest_altitude = FEET_TO_METERS(atof(args));
+#endif
}
void wpt_altitude(xg_string args, const QXmlStreamAttributes* attrv)
enigma_waypt_disp(const waypoint* wpt)
{
char* t;
+#if NEW_STRINGS
+ if (!wpt->shortname.isEmpty()) {
+ // The output might have a space or control character.
+ int i, l = wpt->shortname.length();
+#else
if (wpt->shortname) {
// The output might have a space or control character.
int i, l = strlen(wpt->shortname);
+#endif
t = (char*) xmalloc(l + 1);
char* d = t;
for (i = 0; i < l; i++) {
+#if NEW_STRINGS
+ char s = wpt->shortname[i].cell();
+#else
char s = wpt->shortname[i];
+#endif
if (isgraph(s)) {
*d++ = s;
}
ident = global_opts.synthesize_shortnames ?
mkshort(mkshort_handle, src) :
- wpt->shortname;
+ CSTRc(wpt->shortname);
gbfprintf(psit_file, " %-6s, ", ident);
icon = gt_find_icon_number_from_desc(wpt->icon_descr, PCX);
}
/* route name */
+#if NEW_STRINGS
+ if (rte->rte_name.isEmpty()) {
+ sprintf(hdr, "Route%04x", (unsigned) uniqueValue);
+ rname = xstrdup(hdr);
+ } else {
+ rname = xstrdup(rte->rte_name);
+ }
+#else
if (!rte->rte_name) {
sprintf(hdr, "Route%04x", (unsigned) uniqueValue);
rname = xstrdup(hdr);
} else {
rname = xstrdup(rte->rte_name);
}
+#endif
/* check for psitrex comment sign; replace with '$' */
while ((c = strchr(rname, '#'))) {
*c = '$';
}
/* track name */
+#if NEW_STRINGS
+ if (trk->rte_name.isEmpty()) {
+#else
if (!trk->rte_name) {
+#endif
sprintf(hdr, "Track%04x", (unsigned) uniqueValue);
tname = xstrdup(hdr);
} else {
same_points(const waypoint* A, const waypoint* B)
{
return ( /* !!! We are case-sensitive !!! */
+#if NEW_STRINGS
+ (A->shortname == B->shortname) &&
+#else
(strcmp(A->shortname, B->shortname) == 0) &&
+#endif
(A->latitude == B->latitude) &&
(A->longitude == B->longitude));
}
}
}
- wpt->extra_data = (void*)mkshort(hshort_wpt, wpt->shortname);
+ wpt->extra_data = (void*)mkshort(hshort_wpt, CSTR(wpt->shortname));
waypt_table[waypt_table_ct] = (waypoint*)wpt;
waypt_table_ct++;
{
const waypoint* wa = *(waypoint**)a;
const waypoint* wb = *(waypoint**)b;
-
+#if NEW_STRINGS
+ return wa->shortname.compare(wb->shortname);
+#else
return strcmp(wa->shortname, wb->shortname);
+#endif
}
static void
write_waypoint(gbfile* fout, const waypoint* wpt, const int waypt_no, const char* location)
{
- const char* notes;
+ QString notes;
char* name;
double time;
"Notes=%s" LINE_FEED,
0.0, 0.0,
find_symbol_num(wpt->icon_descr),
- notes
+ CSTR(notes)
);
gbfprintf(fout, "Rel=" LINE_FEED
"RelSet=0" LINE_FEED
"Time=%.10f00000" LINE_FEED,
0.0, -32678.0, 65535.0, time
);
- xfree(notes);
}
static void
write_route_head_cb(const route_head* rte)
{
- char buff[32];
- char* name;
+ QString name;
name = rte->rte_name;
- if ((name == NULL) || (*name == '\0')) {
- snprintf(buff, sizeof(buff), "Route%d", rte_index);
- name = buff;
+ if (name.isEmpty()) {
+ name=QString("Route%1").arg(rte_index);
}
name = mkshort(hshort_rte, name);
gbfprintf(fout, "[Rt%d]" LINE_FEED
"Name=%s" LINE_FEED
"Visible=1" LINE_FEED,
rte_index,
- name
+ CSTR(name)
);
- xfree(name);
-
rte_index++;
rte_wpt_index = 0;
}
tm = *gmtime(&tt);
strftime(buf + 2, sizeof(buf) - 2, "%d%m%y %H%M%S ", &tm);
} else {
- char* name;
-
if (rte_num > 999) {
return;
}
}
return;
}
+ QString name;
if (global_opts.synthesize_shortnames) {
name = mkshort_from_wpt(short_h, wpt);
} else {
if (global_opts.objective == rtedata) {
snprintf(buf + 2, sizeof(buf) - 2, "%03d ", rte_num);
}
- snprintf(buf + 6, sizeof(buf) - 6, "%03d %-9s ", wpt_num, name);
-
- xfree(name);
+ snprintf(buf + 6, sizeof(buf) - 6, "%03d %-9s ", wpt_num, CSTR(name));
}
{
int errors = 5; /* allow this many errors */
unsigned int c, i, state;
- unsigned int rcv_len, calc_cs, rcv_cs;
+ signed int rcv_len;
+ unsigned int calc_cs, rcv_cs;
for (i = 0, state = 0; i < RETRIES && state < sizeof(MSG_START); i++) {
c = rd_char(&errors);
static void
miniHomer_rd_init(const char* fname)
{
- opt_set_location=""; // otherwise it will lead to bus error
+ opt_set_location=NULL; // otherwise it will lead to bus error
skytraq_rd_init(fname); // sets global var serial_handle
mhport=fname;
}
case sm_gcid:
return x1->gc_data->id - x2->gc_data->id;
case sm_shortname:
+#if NEW_STRINGS
+ return x1->shortname.compare(x2->shortname);
+#else
return strcmp(x1->shortname, x2->shortname);
+#endif
case sm_description:
+#if NEW_STRINGS
+ return x1->description.compare(x2->description);
+#else
return strcmp(x1->description, x2->description);
+#endif
case sm_time:
return x1->GetCreationTime().toTime_t() - x2->GetCreationTime().toTime_t();
default:
static int filetype;
static route_head* route;
static queue trackpts;
-static char* rte_name;
-static char* rte_desc;
+static QString rte_name;
+static QString rte_desc;
static waypoint* trkpt_out;
static route_head* trk_out;
trackno++;
if (rte_name != NULL) {
if (trackno > 1) {
- xasprintf(&track->rte_name, "%s (%d)", rte_name, trackno);
+ xasprintf(&track->rte_name, "%s (%d)", CSTR(rte_name), trackno);
} else {
track->rte_name = xstrdup(rte_name);
}
route = NULL;
datum = DATUM_WGS84;
filetype = 28;
- rte_name = rte_desc = NULL;
+ rte_name = rte_desc = QString();
QUEUE_INIT(&trackpts);
}
rd_deinit(void)
{
gbfclose(fin);
- if (rte_name) {
- xfree(rte_name);
- }
- if (rte_desc) {
- xfree(rte_desc);
- }
+ rte_name = QString();
+ rte_desc = QString();
}
static void
return;
}
- if (!rte_name && trk->rte_name) {
+#if NEW_STRINGS
+ if (rte_name.isEmpty() && !trk->rte_name.isEmpty()) {
+#else
+ if (rte_name.isEmpty() && trk->rte_name) {
+#endif
rte_name = trk->rte_name;
rte_desc = trk->rte_desc;
}
}
if (flag == 1) {
- const char* name = wpt->shortname;
+ QString name = wpt->shortname;
if (name == NULL) {
name = "Log paused";
}
- gbfprintf(fout, "\"MP\",\"%s\"", name);
+ gbfprintf(fout, "\"MP\",\"%s\"", CSTR(name));
} else if (flag == 2) {
- const char* name = wpt->shortname;
+ QString name = wpt->shortname;
if (name == NULL) {
name = "Log continued";
}
- gbfprintf(fout, "\"MP\",\"%s\"", name);
+ gbfprintf(fout, "\"MP\",\"%s\"", CSTR(name));
} else {
gbfprintf(fout, "\"TP\"");
}
route_disp_wpt_cb(const waypoint* wpt)
{
if (this_route_valid) {
- char* sn;
+ QString sn;
if (global_opts.synthesize_shortnames) {
sn = mkshort_from_wpt(short_h, wpt);
sn = mkshort(short_h, wpt->shortname);
}
gbfprintf(fout, "\"WP\",\"%s\",%.8lf,%.8lf,%.f\n",
- sn, wpt->latitude, wpt->longitude, ALT(wpt));
- xfree(sn);
+ CSTR(sn), wpt->latitude, wpt->longitude, ALT(wpt));
}
}
gbfprintf(fout, "SOURCE=FILE\n");
gbfprintf(fout, "DATUM=WGS84\n");
- rte_name = NULL;
- rte_desc = NULL;
+ rte_name = QString();
+ rte_desc = QString();
trkpt_out = NULL;
opt_route_index_value = -1; /* take all tracks from data pool */
track_index = 0;
opt_route_index_value = atoi(opt_route_index);
route_disp_all(any_hdr_calc_cb, any_tlr_calc_cb, any_waypt_calc_cb);
gbfprintf(fout, "DISTANCE=%.f\n", all_dist);
- if (rte_name) {
- gbfprintf(fout, "NAME=%s\n", rte_name);
+ if (!rte_name.isEmpty()) {
+ gbfprintf(fout, "NAME=%s\n", CSTR(rte_name));
}
gbfprintf(fout, "[POINTS]\n");
if (route_points > 0) {
track_disp_all(any_hdr_calc_cb, any_tlr_calc_cb, any_waypt_calc_cb);
if (all_track_points > 0) {
- if (rte_name) {
- gbfprintf(fout, "NAME=%s\n", rte_name);
+ if (!rte_name.isEmpty()) {
+ gbfprintf(fout, "NAME=%s\n", CSTR(rte_name));
}
if (minalt != -unknown_alt) {
gbfprintf(fout, "MINALT=%.f\n", minalt);
break;
case 2:
+#if NEW_STRINGS
+ wpt->shortname = QString::fromLatin1(c);
+#else
wpt->shortname = xstrdup(c);
+#endif
break;
case 3:
snprintf(cdate, sizeof(cdate), "%02d/%02d/%04d", tm.tm_mon, tm.tm_mday, tm.tm_year);
snprintf(ctime, sizeof(ctime), "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec);
+ QString sn;
switch (what) {
- char* sn;
case STM_WAYPT:
case STM_RTEPT:
} else {
sn = mkshort(short_h, wpt->shortname);
}
- gbfprintf(fout, "WP,D,%s,", sn);
- xfree(sn);
+ gbfprintf(fout, "WP,D,%s,", CSTR(sn));
break;
case STM_TRKPT:
*/
static char*
-fix_notes(const char* name, char* notes)
+fix_notes(char* name, char* notes)
{
const char* cleft, *cright, *cback;
char* ctmp;
return notes;
}
+static char*
+fix_notes(const QString& name, const QString& notes)
+{
+
+// WTH? fix_notes() modifies the note string...and
+// may reallocate it.
+ char* cname = xstrdup(name);
+ char* cnotes = xstrdup(notes);
+ char *r = fix_notes(cname, cnotes);
+ xfree(cname);
+ xfree(cnotes);
+ return r;
+}
+
static void
waypoint_final()
{
if (version < 2) { /* keep the old behaviour */
wpt_tmp->notes = wpt_tmp->description;
+#if NEW_STRINGS
+ wpt_tmp->description = QString();
+#else
wpt_tmp->description = NULL;
+#endif
}
wpt_tmp->notes = fix_notes(wpt_tmp->shortname, wpt_tmp->notes);
}
xasprintf(&tmpout2, "%s (%d%c %6.0f %7.0f)%s", tmpout1, utmz, utmzc, utme, utmn, altout);
gbfprintf(file_out, "%-16s %59s\n",
- (global_opts.synthesize_shortnames) ? mkshort_from_wpt(mkshort_handle, wpt) : wpt->shortname,
+ (global_opts.synthesize_shortnames) ? CSTRc(mkshort_from_wpt(mkshort_handle, wpt)) : CSTRc(wpt->shortname),
tmpout2);
xfree(tmpout2);
xfree(tmpout1);
xfree(altout);
}
-
+#if NEW_STRINGS
+ if (wpt->description != wpt->shortname) {
+#else
if (strcmp(wpt->description, wpt->shortname)) {
+#endif
gbfprintf(file_out, "%s", CSTRc(wpt->description));
if (!wpt->gc_data->placer.isEmpty()) {
gbfprintf(file_out, " by %s", wpt->gc_data->placer.toUtf8().data());
if (txt_encrypt) {
hint = rot13(wpt->gc_data->hint);
} else {
- hint = xstrdup(wpt->gc_data->hint.toUtf8().data());
+ hint = xstrdup(wpt->gc_data->hint);
}
gbfprintf(file_out, "\nHint: %s\n", hint);
xfree(hint);
}
+#if NEW_STRINGS
+ } else if (!wpt->notes.isEmpty() && (wpt->description.isEmpty() || wpt->notes != wpt->description)) {
+#else
} else if (wpt->notes && (!wpt->description || strcmp(wpt->notes,wpt->description))) {
+#endif
gbfprintf(file_out, "\n%s\n", CSTRc(wpt->notes));
}
gbfprintf(file_out, "%f,%f:%s", lon, lat, pin.toUtf8().data());
if (!nolabels) {
- char* temp = NULL;
- char* desc = csv_stringclean(wpt->description, ":");
+ QString temp;
+ QString desc = csv_stringclean(wpt->description, ":");
if (global_opts.synthesize_shortnames) {
temp = desc;
desc = mkshort(mkshort_whandle, desc);
}
- gbfprintf(file_out, ":%s", desc);
+ gbfprintf(file_out, ":%s", CSTR(desc));
if (temp != NULL) {
desc = temp;
}
- xfree(desc);
}
gbfprintf(file_out, "\n");
}
{
int icon = 1; /* default to "flag" */
int colour = 255; /*default to red */
+#if NEW_STRINGS
+ QString shortname;
+ QString description;
+ if ((wpt->shortname.isEmpty()) || (global_opts.synthesize_shortnames)) {
+ if (!wpt->description.isEmpty()) {
+#else
char* shortname = NULL;
char* description = NULL;
-
if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
if (wpt->description) {
+#endif
if (global_opts.synthesize_shortnames) {
shortname = mkshort_from_wpt(mkshort_handle, wpt);
} else {
shortname = csv_stringclean(wpt->shortname, ",\"");
}
+#if NEW_STRINGS
+ if (wpt->description.isEmpty()) {
+ if (!shortname.isEmpty()) {
+#else
if (! wpt->description) {
if (shortname) {
+#endif
description = csv_stringclean(shortname, ",\"");
} else {
description = xstrdup("");
l = xstrdup(link.url_.toUtf8().data());
}
gbfprintf(file_out, "new\t%.6s\t%.80s\t%08.6f\t%08.6f\t\t\t%.2f\t%d\t%d\t%.128s\n",
- shortname,
- description,
+ CSTRc(shortname),
+ CSTRc(description),
wpt->latitude,
wpt->longitude,
wpt->altitude,
l ? l : ""
);
-
+#if NEW_STRINGS
+#else
if (description) {
xfree(description);
}
if (shortname) {
xfree(shortname);
}
+#endif
if (l) {
xfree(l);
}
return 1;
}
if (wa->wpt->longitude - wb->wpt->longitude == 0) {
+#if NEW_STRINGS
+ return wa->wpt->shortname.compare(wb->wpt->shortname);
+#else
return strcmp(wa->wpt->shortname, wb->wpt->shortname);
+#endif
}
return compare_lon(a,b);
}
return 1;
}
if (wa->wpt->latitude - wb->wpt->latitude == 0) {
+#if NEW_STRINGS
+ return wa->wpt->shortname.compare(wb->wpt->shortname);
+#else
return strcmp(wa->wpt->shortname, wb->wpt->shortname);
+#endif
}
return compare_lat(a,b);
}
newblock->size += 4 * 3 + 1;
/* wpt const part 3 longs, 1 char */
wpt = start[i].wpt;
+#if NEW_STRINGS
+ newblock->size += wpt->description.length() + 1;
+#else
newblock->size += strlen(wpt->description) + 1;
+#endif
}
} else {
if ((maxlat-minlat)>(maxlon-minlon)) {
short int elev;
char tbuf[64];
char c,ocount;
- char* shortname;
- char* description;
+ QString shortname;
+ QString description;
int i;
/* these unknown 4 are probably point properties (color, icon, etc..) */
* and a shortname
*/
+#if NEW_STRINGS
+ if ((wpt->shortname.isEmpty()) || (global_opts.synthesize_shortnames)) {
+ if (!wpt->description.isEmpty()) {
+#else
if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
if (wpt->description) {
+#endif
if (global_opts.synthesize_shortnames) {
shortname = mkshort_from_wpt(mkshort_handle, wpt);
} else {
} else {
shortname = xstrdup(wpt->shortname);
}
-
+#if NEW_STRINGS
+ if (wpt->description.isEmpty()) {
+#else
if (! wpt->description) {
- if (shortname) {
+#endif
+ if (!shortname.isEmpty()) {
description = xstrdup(shortname);
} else {
description = xstrdup("");
elev = (short int) METERS_TO_FEET(wpt->altitude);
/* 1 bytes stringsize for shortname */
- c = strlen(shortname);
+ c = shortname.length();
ocount = 0;
/*
* It's reported the only legal characters are upper case
* count and one to output.
*/
for (i = 0; i < c; i++) {
- char oc = toupper(shortname[i]);
+ char oc = shortname[i].toUpper().cell();
if (isalnum(oc) || oc == ' ') {
ocount++;
}
gbfwrite(&ocount, 1, 1, tpg_file_out);
for (i = 0; i < c; i++) {
- char oc = toupper(shortname[i]);
+ char oc = shortname[i].toUpper().cell();
if (isalnum(oc) || oc == ' ') {
gbfputc(oc, tpg_file_out);
}
} else {
gbfwrite(unknown2, 1, 2, tpg_file_out);
}
-
- xfree(shortname);
- xfree(description);
}
static void
if (opt_name != NULL) {
if ((track->rte_name == NULL) ||
- (case_ignore_str_match(track->rte_name, opt_name) == 0)) {
+ (case_ignore_str_match(CSTRc(track->rte_name), opt_name) == 0)) {
QUEUE_FOR_EACH((queue*)&track->waypoint_list, elem, tmp) {
waypoint* wpt = (waypoint*)elem;
track_del_wpt((route_head*)track, wpt);
} else {
snprintf(buff, sizeof(buff), "%s-%s", opt_title, tbuff);
}
+#if NEW_STRINGS
+ } else if (!track->rte_name.isEmpty()) {
+#else
} else if ((track->rte_name != NULL) && (strlen(track->rte_name) > 0)) {
+#endif
snprintf(buff, sizeof(buff), "%s-%s", CSTRc(track->rte_name), tbuff);
} else {
strncpy(buff, tbuff, sizeof(buff));
}
-
+#if NEW_STRINGS
+ track->rte_name = buff;
+#else
if (track->rte_name != NULL) {
xfree(track->rte_name);
}
track->rte_name = xstrdup(buff);
+#endif
}
static void
} else {
strncpy(buff, opt_title, sizeof(buff));
}
-
+#if NEW_STRINGS
+ track->rte_name = buff;
+#else
if (track->rte_name != NULL) {
xfree(track->rte_name);
}
track->rte_name = xstrdup(buff);
+#endif
}
/*******************************************************************************
dest = route_head_alloc();
dest->rte_num = src->rte_num;
/* name in the form TRACKNAME #n */
+#if NEW_STRINGS
+ if (!src->rte_name.isEmpty()) {
+#else
if (src->rte_name) {
+#endif
xasprintf(&dest->rte_name, "%s #%d", CSTRc(src->rte_name), ++trk_seg_num);
}
static route_head* current_rte;
static char* opt_routes, *opt_tracks, *opt_waypts, *opt_delete, *rpt_name_digits, *opt_rpt_name;
-
+#if NEW_STRINGS
+static QString current_namepart;
+#else
static char* current_namepart;
+#endif
static int name_digits, use_src_name;
transform_rte_disp_hdr_cb(const route_head* rte)
{
current_namepart = RPT;
+#if NEW_STRINGS
+ if (!rte->rte_name.isEmpty() && use_src_name) {
+#else
if (rte->rte_name && *rte->rte_name && use_src_name) {
+#endif
current_namepart = rte->rte_name;
}
if (current_target == 'T') {
current_trk = route_head_alloc();
track_add_head(current_trk);
+#if NEW_STRINGS
+ if (!rte->rte_name.isEmpty()) {
+#else
if (rte->rte_name && *rte->rte_name) {
+#endif
xasprintf(¤t_trk->rte_desc, "Generated from route %s", CSTRc(rte->rte_name));
current_trk->rte_name = xstrdup(rte->rte_name); /* name the new trk */
}
transform_trk_disp_hdr_cb(const route_head* trk)
{
current_namepart = RPT;
+#if NEW_STRINGS
+ if (!trk->rte_name.isEmpty() && use_src_name) {
+#else
if (trk->rte_name && *trk->rte_name && use_src_name) {
+#endif
current_namepart = trk->rte_name;
}
if (current_target == 'R') {
current_rte = route_head_alloc();
route_add_head(current_rte);
+#if NEW_STRINGS
+ if (!trk->rte_name.isEmpty()) {
+ current_rte->rte_desc = "Generated from track ";
+ current_rte->rte_desc += trk->rte_name;
+ current_rte->rte_name = trk->rte_name; /* name the new rte */
+ }
+#else
if (trk->rte_name && *trk->rte_name) {
xasprintf(¤t_rte->rte_desc, "Generated from track %s", CSTRc(trk->rte_name));
current_rte->rte_name = xstrdup(trk->rte_name); /* name the new rte */
}
+#endif
}
}
{
gbfprintf(fout, "#####\n");
fatal(MYNAME ": %s (%s) is outside of convertable area of grid \"%s\"!\n",
+#if NEW_STRINGS
+ wpt->shortname.isEmpty() ? "Waypoint" : CSTR(wpt->shortname),
+#else
wpt->shortname ? CSTRc(wpt->shortname) : "Waypoint",
+#endif
pretty_deg_format(wpt->latitude, wpt->longitude, 'd', NULL, 0),
gt_get_mps_grid_longname(unicsv_grid_idx, MYNAME));
}
gbfputs(t.trimmed(), fout);
}
-#if NEW_STRINGS
-static void
-unicsv_print_str(const String& s)
-{
- unicsv_print_str(s.s_);
-}
-#endif
-
static void
unicsv_print_data_time(const QDateTime& idt)
{
if (!wpt->icon_descr.isNull()) {
gb_setbit(&unicsv_outp_flags, fld_symbol);
}
+#if NEW_STRINGS
+ if (!wpt->description.isEmpty() && shortname != wpt->description) {
+#else
if (wpt->description && *wpt->description && shortname != wpt->description) {
+#endif
gb_setbit(&unicsv_outp_flags, fld_description);
}
+#if NEW_STRINGS
+ if (!wpt->notes.isEmpty() && shortname != wpt->notes) {
+ if ((wpt->description.isEmpty()) || (wpt->description != wpt->notes)) {
+#else
if (wpt->notes && *wpt->notes && shortname != wpt->notes) {
if ((! wpt->description) || (strcmp(wpt->description, wpt->notes) != 0)) {
+#endif
gb_setbit(&unicsv_outp_flags, fld_notes);
}
}
{
double lat, lon, alt;
char* cout = NULL;
- const char* shortname;
garmin_fs_t* gmsd;
const geocache_data* gc_data = NULL;
unicsv_waypt_ct++;
- shortname = (wpt->shortname) ? CSTRc(wpt->shortname) : "";
+ QString shortname = wpt->shortname;
gmsd = GMSD_FIND(wpt);
if (unicsv_datum_idx == DATUM_WGS84) {
double usec = fmod(1000000*seconds+0.5,1000000);
wpt_tmp->SetCreationTime(mkgmtime(&tmStruct), lround(usec/1000.0));
+#if NEW_STRINGS
+ wpt_tmp->shortname = QString().sprintf("WP%04d", ++serial);
+#else
wpt_tmp->shortname = (char*) xcalloc(16,1);
snprintf(wpt_tmp->shortname, 15 , "WP%04d", ++serial);
+#endif
WAYPT_SET(wpt_tmp, speed, KNOTS_TO_MPS(speed)); /* meters per second */
WAYPT_SET(wpt_tmp, course, course);
*/
waypoint* tmp = new waypoint;
*tmp = *wpt;
-
+#if NEW_STRINGS
+#else
if (wpt->shortname) {
tmp->shortname = xstrdup(wpt->shortname);
}
if (wpt->notes) {
tmp->notes = xstrdup(wpt->notes);
}
+#endif
tmp->icon_descr = wpt->icon_descr;
* try to be sure that we have these fields even if just by
* copying them from elsewhere.
*/
+#if NEW_STRINGS
+ // Note tests for isNull here as some formats intentionally set "".
+ // This is kind of goofy, but it emulates the C string implementation.
+ if (wpt->shortname.isNull()) {
+ if (!wpt->description.isNull()) {
+ wpt->shortname = wpt->description;
+ } else if (!wpt->notes.isNull()) {
+ wpt->shortname = wpt->notes;
+ } else {
+ QString n;
+ n.sprintf("%03d", waypt_ct);
+ wpt->shortname = QString("WPT%1").arg(n);
+ }
+ }
+#else
if (wpt->shortname == NULL) {
if (wpt->description) {
wpt->shortname = xstrdup(wpt->description);
wpt->shortname = sn;
}
}
+#endif
+#if NEW_STRINGS
+ if (wpt->description.isEmpty()) {
+ if (!wpt->notes.isNull()) {
+ wpt->description = wpt->notes;
+ } else {
+ if (!wpt->shortname.isNull()) {
+ wpt->description = wpt->shortname;
+ }
+ }
+ }
+#else
if (wpt->description == NULL || strlen(wpt->description) == 0) {
if (wpt->description) {
xfree(wpt->description);
}
}
}
+#endif
update_common_traits(wpt);
}
printposn(wpt->latitude,1);
printposn(wpt->longitude,0);
-
+#if NEW_STRINGS
+ if (!wpt->description.isEmpty()) {
+#else
if (wpt->description) {
+#endif
char* tmpdesc = xstrdup(wpt->description);
printf("%s/%s",
global_opts.synthesize_shortnames ?
mkshort(mkshort_handle, tmpdesc) :
- wpt->shortname,
+ CSTRc(wpt->shortname),
tmpdesc);
if (tmpdesc) {
xfree(tmpdesc);
/*
* This and waypt_dupe should be closely synced.
*/
+#if NEW_STRINGS
+#else
if (wpt->shortname) {
xfree(wpt->shortname);
}
if (wpt->notes) {
xfree(wpt->notes);
}
+#endif
if (wpt->gc_data != &empty_gc_data) {
geocache_data* gc_data = (geocache_data*)wpt->gc_data;
ap_lat=0.0;
ap_lon=0.0;
}
+#if NEW_STRINGS
+// anything here involving 'xstrdup' should be fixed by fixing the underlying data type.
+void wfff_mac(const QString& args, const QXmlStreamAttributes* unused) { ap_mac = xstrdup(args); }
+void wfff_ssid(const QString& args, const QXmlStreamAttributes* unused) { ap_ssid = xstrdup(args); }
+void wfff_type(const QString& args, const QXmlStreamAttributes* unused) { ap_type = xstrdup(args); }
+void wfff_mnrssi(const QString& args, const QXmlStreamAttributes* unused) { ap_mnrssi = args.toDouble(); }
+void wfff_mxrssi(const QString& args, const QXmlStreamAttributes* unused) { ap_mxrssi = args.toDouble(); }
+void wfff_chan(const QString& args, const QXmlStreamAttributes* unused) { ap_chan = args.toInt(); }
+void wfff_first(const QString& args, const QXmlStreamAttributes* unused) { ap_first = xml_parse_time(args).toTime_t(); }
+void wfff_last(const QString& args, const QXmlStreamAttributes* unused) { ap_last = xstrdup(args); }
+void wfff_wep(const QString& args, const QXmlStreamAttributes* unused) { ap_wep = xstrdup(args); }
+void wfff_hdop(const QString& args, const QXmlStreamAttributes* unused) { ap_hdop = args.toDouble(); }
+void wfff_lat(const QString& args, const QXmlStreamAttributes* unused) { ap_lat = args.toDouble(); }
+void wfff_lon(const QString& args, const QXmlStreamAttributes* unused) { ap_lon = args.toDouble(); }
+#else
void wfff_mac(xg_string args, const QXmlStreamAttributes* unused)
{
ap_lon = atof(args);
}
}
+#endif
/* End of AP Block, set waypoint and add */
static long tosscount=0;
/* Tweak incoming name if we don't have a fix */
switch (wpt->fix) {
case fix_none:
+#if NEW_STRINGS
+ wpt->shortname = "ESTIMATED Position";
+#else
if (wpt->shortname) {
xfree(wpt->shortname);
}
wpt->shortname = xstrdup("ESTIMATED Position");
+#endif
break;
default:
break;
void wpt_lat(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->latitude = args.toDouble();
+#else
wpt_tmp->latitude = atof(args);
+#endif
}
void wpt_lon(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ wpt_tmp->longitude = args.toDouble();
+#else
wpt_tmp->longitude = atof(args);
+#endif
}
void wpt_addr(xg_string args, const QXmlStreamAttributes* unused)
{
+#if NEW_STRINGS
+ if (!wpt_tmp->notes.isEmpty()) {
+ wpt_tmp->notes += as;
+ }
+ wpt_tmp->notes += args;
+#else
if (wpt_tmp->notes) {
wpt_tmp->notes = xstrappend(wpt_tmp->notes, as);
}
wpt_tmp->notes = xstrappend(wpt_tmp->notes, args);
+#endif
}
ff_vecs_t yahoo_vecs = {